diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 176a458..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto diff --git a/.gitignore b/.gitignore index 0db216b..ade14b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.DS_Store npm-debug.log node_modules diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 01915a7..0000000 --- a/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 donaldpipowitch - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..ade025f --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014 Donald Pipowitch + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index f0f1883..5998c2b 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ -# Beautify - -[Atom package](https://github.com/einars/js-beautify) - -> [Beautify](https://github.com/mishoo/UglifyJS2) HTML, CSS and Javascript in Atom. +# atom-beautify package +[Beautify](https://github.com/einars/js-beautify) HTML, CSS and Javascript in Atom. ## Usage Open the Command Palette, and type `Beautify`. This will beautify JS, HTML or CSS files. It will only beautify selected text, if a selection is found - if not, the whole file will be beautified. +You can also type `ctrl-alt-b` as a shortcut or click `Packages > Beautify` in the menu. ## License diff --git a/keymaps/atom-beautify.cson b/keymaps/atom-beautify.cson new file mode 100644 index 0000000..f8f25b6 --- /dev/null +++ b/keymaps/atom-beautify.cson @@ -0,0 +1,11 @@ +# Keybindings require three things to be fully defined: A selector that is +# matched against the focused element, the keystroke and the command to +# execute. +# +# Below is a basic keybinding which registers on all platforms by applying to +# the root workspace element. + +# For more detailed documentation see +# https://atom.io/docs/latest/advanced/keymaps +'.workspace .editor:not(.mini)': + 'ctrl-alt-b': 'beautify' diff --git a/index.js b/lib/atom-beautify.js similarity index 100% rename from index.js rename to lib/atom-beautify.js diff --git a/menus/atom-beautify.cson b/menus/atom-beautify.cson new file mode 100644 index 0000000..dbc366a --- /dev/null +++ b/menus/atom-beautify.cson @@ -0,0 +1,14 @@ +# See https://atom.io/docs/latest/creating-a-package#menus for more details +'context-menu': + '.workspace .editor:not(.mini)': + 'Enable atom-beautify': 'beautify' + +'menu': [ + { + 'label': 'Packages' + 'submenu': [ + 'label': 'Beautify' + 'command': 'beautify' + ] + } +] diff --git a/package.json b/package.json index 6e38383..d1c1a81 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,21 @@ { - "name": "beautify", + "name": "atom-beautify", + "main": "./lib/atom-beautify", "version": "0.0.0", + "private": true, "description": "Beautify HTML, CSS and Javascript in Atom", - "license": "MIT", + "activationEvents": ["beautify"], "repository": "https://github.com/donaldpipowitch/atom-beautify", - "activationEvents": [ - "beautify" - ], + "license": "MIT", "author": { "name": "Donald Pipowitch", "email": "pipo@senaeh.de", "url": "https://github.com/donaldpipowitch" }, "engines": { - "atom": ">=0.50.0" + "atom": ">0.50.0" }, - "dependencies": {}, - "devDependencies": { + "dependencies": { "js-beautify": "~1.4.2" } } diff --git a/spec/atom-beautify-spec.coffee b/spec/atom-beautify-spec.coffee new file mode 100644 index 0000000..a90db6e --- /dev/null +++ b/spec/atom-beautify-spec.coffee @@ -0,0 +1,29 @@ +AtomBeautify = require '../lib/atom-beautify' + +# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. +# +# To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` +# or `fdescribe`). Remove the `f` to unfocus the block. + +describe "AtomBeautify", -> + activationPromise = null + + beforeEach -> + atom.workspaceView = new WorkspaceView + activationPromise = atom.packages.activatePackage('atomBeautify') + +# describe "when the beautify event is triggered", -> +# it "attaches and then detaches the view", -> +# expect(atom.workspaceView.find('.atom-beautify')).not.toExist() +# +# # This is an activation event, triggering it will cause the package to be +# # activated. +# atom.workspaceView.trigger 'beautify' +# +# waitsForPromise -> +# activationPromise +# +# runs -> +# expect(atom.workspaceView.find('.atom-beautify')).toExist() +# atom.workspaceView.trigger 'beautify' +# expect(atom.workspaceView.find('.atom-beautify')).not.toExist()