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

edit: scoped packages #75

Merged
merged 3 commits into from Nov 26, 2018
Merged

edit: scoped packages #75

merged 3 commits into from Nov 26, 2018

Conversation

larsgw
Copy link
Contributor

@larsgw larsgw commented Oct 3, 2018

  • handle scoped packages properly
  • change usage info so it matches old (and current) behavior.

There's an easier way to do this, but that handles some edge cases differently (namely, ignore leading and trailing forward slashes instead of trying to edit root folders), and I don't know if that is allowed.

diff --git a/lib/edit.js b/lib/edit.js
index 48bcd5d34..2b2a02224 100644
--- a/lib/edit.js
+++ b/lib/edit.js
@@ -21,7 +21,7 @@ function edit (args, cb) {
       "No editor set.  Set the 'editor' config, or $EDITOR environ."
     ))
   }
-  p = p.split('/')
+  p = (p.match(/(@[^/]+\/[^/]+|[^/]+)/g) || [])
     .join('/node_modules/')
     .replace(/(\/node_modules)+/, '/node_modules')
   var f = path.resolve(npm.dir, p)

See https://npm.community/t/2258.

@larsgw larsgw requested a review from a team as a code owner October 3, 2018 18:49
Copy link
Contributor

@iarna iarna left a comment

Choose a reason for hiding this comment

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

A small doc update to do here, either by @larsgw or when we land this. Otherwise, yes, let's get this in!

@@ -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>...]'
Copy link
Contributor

@iarna iarna Oct 4, 2018

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!

Copy link
Contributor Author

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.

@@ -22,6 +22,20 @@ function edit (args, cb) {
))
}
p = p.split('/')
// combine scoped parts
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@larsgw
Copy link
Contributor Author

larsgw commented Oct 24, 2018

Ping? I added the docs, is there something else?

@zkat zkat changed the base branch from latest to release-next November 13, 2018 15:02
@zkat zkat added the semver:patch semver patch level for changes label Nov 13, 2018
@zkat zkat merged commit a34246b into npm:release-next Nov 26, 2018
zkat pushed a commit that referenced this pull request Dec 10, 2018
* edit: fix handling of scoped packages

* edit: fix usage info

* docs: fix docs for the npm-edit command

PR-URL: #75
Credit: @larsgw
Reviewed-By: @iarna
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch semver patch level for changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants