From 1954b30a789b8e904704182b744df45b3216af4f Mon Sep 17 00:00:00 2001 From: Luis Davim Date: Sun, 11 Sep 2016 21:22:11 +0100 Subject: [PATCH 1/3] Allow sequences of commands --- lib/atom-alias-command.coffee | 7 ++++++- package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/atom-alias-command.coffee b/lib/atom-alias-command.coffee index 2ee000e..519b60b 100644 --- a/lib/atom-alias-command.coffee +++ b/lib/atom-alias-command.coffee @@ -1,10 +1,15 @@ {CompositeDisposable} = require 'atom' +typeIsArray = Array.isArray || ( value ) -> return {}.toString.call( value ) is '[object Array]' + module.exports = aliasCommand = (as, {orig, scope}) -> scope ?= 'atom-workspace' aliasCommand.subscriptions.add( atom.commands.add scope, as, (event) -> - atom.commands.dispatch event.target, orig + if typeIsArray orig + atom.commands.dispatch event.target, o for o in orig + else + atom.commands.dispatch event.target, orig ) aliasCommand.activate = -> diff --git a/package.json b/package.json index ab07c66..5cbc990 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alias-command", "main": "./lib/atom-alias-command", - "version": "1.0.1", + "version": "1.0.2", "description": "Register existing commands with new names", "keywords": [ "alias", From 95f7fa279c922b5e3ce67c4e25ecf438ad92cbb3 Mon Sep 17 00:00:00 2001 From: Luis Davim Date: Mon, 19 Sep 2016 20:09:01 +0100 Subject: [PATCH 2/3] updated documentation --- README.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d39c21b..ac202db 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,11 @@ aliasCommand 'package-control:install', aliasCommand 'grammar-selector:set-syntax', orig: 'grammar-selector:show' scope: 'atom-editor' + +# Composed commands +# You can pass it an array of commands +aliasCommand 'wq', +orig: ['core:save', 'core:close'] ``` ## Running Tests diff --git a/package.json b/package.json index 5cbc990..ab07c66 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alias-command", "main": "./lib/atom-alias-command", - "version": "1.0.2", + "version": "1.0.1", "description": "Register existing commands with new names", "keywords": [ "alias", From befedcf0f859852a8a28d41ef505d6ef3b1423ed Mon Sep 17 00:00:00 2001 From: Luis Davim Date: Sun, 11 Sep 2016 21:22:11 +0100 Subject: [PATCH 3/3] Allow sequences of commands --- README.md | 5 +++++ lib/atom-alias-command.coffee | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d39c21b..ac202db 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,11 @@ aliasCommand 'package-control:install', aliasCommand 'grammar-selector:set-syntax', orig: 'grammar-selector:show' scope: 'atom-editor' + +# Composed commands +# You can pass it an array of commands +aliasCommand 'wq', +orig: ['core:save', 'core:close'] ``` ## Running Tests diff --git a/lib/atom-alias-command.coffee b/lib/atom-alias-command.coffee index 2ee000e..519b60b 100644 --- a/lib/atom-alias-command.coffee +++ b/lib/atom-alias-command.coffee @@ -1,10 +1,15 @@ {CompositeDisposable} = require 'atom' +typeIsArray = Array.isArray || ( value ) -> return {}.toString.call( value ) is '[object Array]' + module.exports = aliasCommand = (as, {orig, scope}) -> scope ?= 'atom-workspace' aliasCommand.subscriptions.add( atom.commands.add scope, as, (event) -> - atom.commands.dispatch event.target, orig + if typeIsArray orig + atom.commands.dispatch event.target, o for o in orig + else + atom.commands.dispatch event.target, orig ) aliasCommand.activate = ->