apm icon indicating copy to clipboard operation
apm copied to clipboard

use common npm abbreviations, fixes #435

Open bronson opened this issue 9 years ago • 5 comments

Fixes #435

Also updated some tests to use the abbreviations where convenient.

bronson avatar Dec 29 '15 00:12 bronson

Ha, sure. Added @Alhadis's suggestion and rebased to master.

bronson avatar Oct 14 '16 22:10 bronson

Alas, it looks like CI on master is broken. The failure isn't related to this patch.

bronson avatar Oct 14 '16 22:10 bronson

I would much prefer that new specs are added for the abbreviations, rather than changing the existing command names (e.g. install > i). This will ensure there are not regressions for the full command names.

joefitzgerald avatar Jan 16 '17 18:01 joefitzgerald

Heh, maybe no tests needed? https://github.com/atom/apm/commit/94a730e1231c59f890296977027107952a50321a

bronson avatar Sep 04 '17 21:09 bronson

OK, the patch has been updated to just specify the abbreviations, not test them.

Agreed, it would be nice to have specs for the abbreviations. I don't see a way to do it that looks clean though... Best I came up with would be to write tests like this:

describe 'aliases for install', ->
  runs ->
    expect(apm.findCommand(['i'])).toBe Install

Which requires the following patch to apm-cli.coffee:

diff --git a/src/apm-cli.coffee b/src/apm-cli.coffee
index fde6865..ff0a647 100644
--- a/src/apm-cli.coffee
+++ b/src/apm-cli.coffee
@@ -154,7 +154,12 @@ getPythonVersion = (callback) ->
         version = version?.trim()
       callback(version)
 
+findCommand = (command) ->
+  commands[command]
+
 module.exports =
+  findCommand: findCommand
+
   run: (args, callback) ->
     config.setupApmRcFile()
     options = parseOptions(args)
@@ -203,7 +208,7 @@ module.exports =
         else
           showHelp(options)
         options.callback()
-      else if Command = commands[command]
+      else if Command = findCommand(command)
         new Command().run(options)
       else
         options.callback("Unrecognized command: #{command}")

Can finish doing that if you think it's worth it.

bronson avatar Sep 04 '17 22:09 bronson