-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
edit: scoped packages #75
Changes from all commits
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// open the package folder in the $EDITOR | ||
|
||
module.exports = edit | ||
edit.usage = 'npm edit <pkg>[@<version>]' | ||
edit.usage = 'npm edit <pkg>[/<subpkg>...]' | ||
|
||
edit.completion = require('./utils/completion/installed-shallow.js') | ||
|
||
|
@@ -22,6 +22,20 @@ function edit (args, cb) { | |
)) | ||
} | ||
p = p.split('/') | ||
// combine scoped parts | ||
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. Ordinarily I'd ask for tests, but we don't have any existing tests for this route, this is a interactive route and this change is reasonably eyeballable, so I'm inclined to take this without them. 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. Yeah, I tried making tests but I'm not too familiar with all the mocking environments yet, and without something to work with I wasn't sure how to. |
||
.reduce(function (parts, part) { | ||
if (parts.length === 0) { | ||
return [part] | ||
} | ||
var lastPart = parts[parts.length - 1] | ||
// check if previous part is the first part of a scoped package | ||
if (lastPart[0] === '@' && !lastPart.includes('/')) { | ||
parts[parts.length - 1] += '/' + part | ||
} else { | ||
parts.push(part) | ||
} | ||
return parts | ||
}, []) | ||
.join('/node_modules/') | ||
.replace(/(\/node_modules)+/, '/node_modules') | ||
var f = path.resolve(npm.dir, p) | ||
|
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.
I looked into how this summary got messed up, and it goes back to the edit docs having been wrong since 2011, and folks patching this usage summary to match them.
I would like to see the summary in
doc/cli/npm-edit.md
updated to match!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.
Will do, didn't see those were in the repo too.