-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Changes from 1 commit
a3e093b
5968661
94ea9d9
1c58bf4
ace8d0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 [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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to have > 0 instead of !==0. |
||
canonic_module_name = canonic_module_name.substr(0,canonic_module_name.lastIndexOf("@")); | ||
} | ||
|
||
//pm2 install module#some-branch | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you just add a test with multiple @. |
||
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'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests on 0.12 failed cause startsWidth is not supported :(
I think we should write test just like this :
if (canonic_module_name[0] !== "@"){