Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/scoped package support #3453

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you just add a test with multiple @.
Like @org/[email protected]
Just to ensure we test all cases.

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