From dc01118234a2405227e50efd062358d7b9078841 Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Wed, 3 Oct 2018 20:36:57 +0200 Subject: [PATCH 1/3] edit: fix handling of scoped packages --- lib/edit.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/edit.js b/lib/edit.js index 48bcd5d346cad..5cf2c55057c26 100644 --- a/lib/edit.js +++ b/lib/edit.js @@ -22,6 +22,20 @@ function edit (args, cb) { )) } p = p.split('/') + // combine scoped parts + .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) From 441aaaf4dc375bea8518aea10350c327b9e4843c Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Wed, 3 Oct 2018 20:39:45 +0200 Subject: [PATCH 2/3] edit: fix usage info --- lib/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/edit.js b/lib/edit.js index 5cf2c55057c26..2e8b339e998bd 100644 --- a/lib/edit.js +++ b/lib/edit.js @@ -2,7 +2,7 @@ // open the package folder in the $EDITOR module.exports = edit -edit.usage = 'npm edit [@]' +edit.usage = 'npm edit [/...]' edit.completion = require('./utils/completion/installed-shallow.js') From 717236493ba4802200c65bae02814ee1e4496a1a Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Thu, 4 Oct 2018 22:37:07 +0200 Subject: [PATCH 3/3] docs: fix docs for the npm-edit command --- doc/cli/npm-edit.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/cli/npm-edit.md b/doc/cli/npm-edit.md index 89ecfa877eeac..f9913a015ad3b 100644 --- a/doc/cli/npm-edit.md +++ b/doc/cli/npm-edit.md @@ -3,12 +3,14 @@ npm-edit(1) -- Edit an installed package ## SYNOPSIS - npm edit [@] + npm edit [/...] ## DESCRIPTION -Opens the package folder in the default editor (or whatever you've -configured as the npm `editor` config -- see `npm-config(7)`.) +Selects a (sub)dependency in the current +working directory and opens the package folder in the default editor +(or whatever you've configured as the npm `editor` config -- see +`npm-config(7)`.) After it has been edited, the package is rebuilt so as to pick up any changes in compiled packages.