Skip to content

Commit

Permalink
Merge pull request #3453 from deltasource/hotfix/scoped-package-support
Browse files Browse the repository at this point in the history
Hotfix/scoped package support
  • Loading branch information
wallet77 authored Feb 8, 2018
2 parents 0d2b717 + ace8d0c commit 974f9bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lib/Utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]
if(canonic_module_name.indexOf('@') !== -1) {
canonic_module_name = canonic_module_name.split('@')[0];
//pm2 install @somescope/[email protected]
if(canonic_module_name.lastIndexOf('@') > 0) {
canonic_module_name = canonic_module_name.substr(0,canonic_module_name.lastIndexOf("@"));
}

//pm2 install module#some-branch
Expand Down
3 changes: 2 additions & 1 deletion test/interface/utility.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 974f9bf

Please sign in to comment.