diff --git a/lib/Utility.js b/lib/Utility.js index a6f1f318e..71f65b03c 100644 --- a/lib/Utility.js +++ b/lib/Utility.js @@ -223,12 +223,14 @@ var Utility = module.exports = { //pm2 install username/module else if(canonic_module_name.indexOf('/') !== -1) { - canonic_module_name = canonic_module_name.split('/')[1]; + if (canonic_module_name.charAt(0) !== "@"){ + canonic_module_name = canonic_module_name.split('/')[1]; + } } - //pm2 install module@2.1.0-beta - if(canonic_module_name.indexOf('@') !== -1) { - canonic_module_name = canonic_module_name.split('@')[0]; + //pm2 install @somescope/module@2.1.0-beta + if(canonic_module_name.lastIndexOf('@') > 0) { + canonic_module_name = canonic_module_name.substr(0,canonic_module_name.lastIndexOf("@")); } //pm2 install module#some-branch diff --git a/test/interface/utility.mocha.js b/test/interface/utility.mocha.js index e5e76adc9..d2c1c7bd3 100644 --- a/test/interface/utility.mocha.js +++ b/test/interface/utility.mocha.js @@ -18,7 +18,8 @@ describe('Utility', function() { assert(Utility.getCanonicModuleName('ma-zal/pm2-slack') === 'pm2-slack'); assert(Utility.getCanonicModuleName('ma-zal/pm2-slack#own-branch') === 'pm2-slack'); assert(Utility.getCanonicModuleName('pm2-slack') === 'pm2-slack'); - assert(Utility.getCanonicModuleName('@org/pm2-slack') === 'pm2-slack'); + assert(Utility.getCanonicModuleName('@org/pm2-slack') === '@org/pm2-slack'); + assert(Utility.getCanonicModuleName('@org/pm2-slack@latest') === '@org/pm2-slack'); assert(Utility.getCanonicModuleName('git+https://github.com/user/pm2-slack') === 'pm2-slack'); assert(Utility.getCanonicModuleName('git+https://github.com/user/pm2-slack.git') === 'pm2-slack'); assert(Utility.getCanonicModuleName('file:///home/user/pm2-slack') === 'pm2-slack');