From 1c5d6ce64f4eb214a4dbc1221c728657e9624376 Mon Sep 17 00:00:00 2001 From: Daan Kets Date: Wed, 7 Feb 2018 09:13:22 +0200 Subject: [PATCH 1/4] Support for scoped package names --- lib/Utility.js | 10 ++++++---- test/interface/utility.mocha.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Utility.js b/lib/Utility.js index 169d86fd8..ee51e3f8a 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.startsWith("@")){ + 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..1cb89389a 100644 --- a/test/interface/utility.mocha.js +++ b/test/interface/utility.mocha.js @@ -18,7 +18,7 @@ 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('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'); From 57c5a746faa5567cc09fb94a08c91f6434601c38 Mon Sep 17 00:00:00 2001 From: Daan Kets Date: Wed, 7 Feb 2018 09:14:55 +0200 Subject: [PATCH 2/4] Hotfix version increased --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6db86cc86..40f26bec3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pm2", "preferGlobal": true, - "version": "2.9.3", + "version": "2.9.4", "engines": { "node": ">=0.12" }, From ea6f3a1d9c80f8a609109e1cef40a98138af8291 Mon Sep 17 00:00:00 2001 From: Daan Kets Date: Thu, 8 Feb 2018 11:23:51 +0100 Subject: [PATCH 3/4] Added one test case, fixed a small bug - Additional test case for @scope/module@tag - Fixed a bug for checking the position of the last @ in the module name, that could trigger on -1. --- lib/Utility.js | 2 +- test/interface/utility.mocha.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Utility.js b/lib/Utility.js index d0e3ab672..a0617db68 100644 --- a/lib/Utility.js +++ b/lib/Utility.js @@ -229,7 +229,7 @@ var Utility = module.exports = { } //pm2 install @somescope/module@2.1.0-beta - if(canonic_module_name.lastIndexOf('@') !== 0) { + if(canonic_module_name.lastIndexOf('@') > 0) { canonic_module_name = canonic_module_name.substr(0,canonic_module_name.lastIndexOf("@")); } diff --git a/test/interface/utility.mocha.js b/test/interface/utility.mocha.js index 1cb89389a..d2c1c7bd3 100644 --- a/test/interface/utility.mocha.js +++ b/test/interface/utility.mocha.js @@ -19,6 +19,7 @@ describe('Utility', function() { assert(Utility.getCanonicModuleName('ma-zal/pm2-slack#own-branch') === 'pm2-slack'); assert(Utility.getCanonicModuleName('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'); From b2c2b8e80f0e4076eae90e51ba7a4da7b2a48b08 Mon Sep 17 00:00:00 2001 From: Daan Kets Date: Thu, 8 Feb 2018 12:03:28 +0100 Subject: [PATCH 4/4] Fix for node 0.12 test (no String.startsWith()) --- lib/Utility.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Utility.js b/lib/Utility.js index a0617db68..71f65b03c 100644 --- a/lib/Utility.js +++ b/lib/Utility.js @@ -223,7 +223,7 @@ var Utility = module.exports = { //pm2 install username/module else if(canonic_module_name.indexOf('/') !== -1) { - if (!canonic_module_name.startsWith("@")){ + if (canonic_module_name.charAt(0) !== "@"){ canonic_module_name = canonic_module_name.split('/')[1]; } }