File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,12 +3,14 @@ npm-edit(1) -- Edit an installed package
33
44## SYNOPSIS
55
6- npm edit <pkg>[@<version> ]
6+ npm edit <pkg>[/<subpkg>... ]
77
88## DESCRIPTION
99
10- Opens the package folder in the default editor (or whatever you've
11- configured as the npm ` editor ` config -- see ` npm-config(7) ` .)
10+ Selects a (sub)dependency in the current
11+ working directory and opens the package folder in the default editor
12+ (or whatever you've configured as the npm ` editor ` config -- see
13+ ` npm-config(7) ` .)
1214
1315After it has been edited, the package is rebuilt so as to pick up any
1416changes in compiled packages.
Original file line number Diff line number Diff line change 22// open the package folder in the $EDITOR
33
44module . exports = edit
5- edit . usage = 'npm edit <pkg>[@<version> ]'
5+ edit . usage = 'npm edit <pkg>[/<subpkg>... ]'
66
77edit . completion = require ( './utils/completion/installed-shallow.js' )
88
@@ -22,6 +22,20 @@ function edit (args, cb) {
2222 ) )
2323 }
2424 p = p . split ( '/' )
25+ // combine scoped parts
26+ . reduce ( function ( parts , part ) {
27+ if ( parts . length === 0 ) {
28+ return [ part ]
29+ }
30+ var lastPart = parts [ parts . length - 1 ]
31+ // check if previous part is the first part of a scoped package
32+ if ( lastPart [ 0 ] === '@' && ! lastPart . includes ( '/' ) ) {
33+ parts [ parts . length - 1 ] += '/' + part
34+ } else {
35+ parts . push ( part )
36+ }
37+ return parts
38+ } , [ ] )
2539 . join ( '/node_modules/' )
2640 . replace ( / ( \/ n o d e _ m o d u l e s ) + / , '/node_modules' )
2741 var f = path . resolve ( npm . dir , p )
You can’t perform that action at this time.
0 commit comments