@@ -2,17 +2,17 @@ module.exports = unbuild
2
2
module . exports . rmStuff = rmStuff
3
3
unbuild . usage = 'npm unbuild <folder>\n(this is plumbing)'
4
4
5
- var readJson = require ( 'read-package-json' )
6
- var gentlyRm = require ( './utils/gently-rm.js' )
7
- var npm = require ( './npm.js' )
8
- var path = require ( 'path' )
9
- var isInside = require ( 'path-is-inside' )
10
- var lifecycle = require ( './utils/lifecycle.js' )
11
- var asyncMap = require ( 'slide' ) . asyncMap
12
- var chain = require ( 'slide' ) . chain
13
- var log = require ( 'npmlog' )
14
- var build = require ( './build.js' )
15
- var output = require ( './utils/output.js' )
5
+ const readJson = require ( 'read-package-json' )
6
+ const gentlyRm = require ( './utils/gently-rm.js' )
7
+ const npm = require ( './npm.js' )
8
+ const path = require ( 'path' )
9
+ const isInside = require ( 'path-is-inside' )
10
+ const lifecycle = require ( './utils/lifecycle.js' )
11
+ const asyncMap = require ( 'slide' ) . asyncMap
12
+ const chain = require ( 'slide' ) . chain
13
+ const log = require ( 'npmlog' )
14
+ const build = require ( './build.js' )
15
+ const output = require ( './utils/output.js' )
16
16
17
17
// args is a list of folders.
18
18
// remove any bins/etc, and then delete the folder.
@@ -30,7 +30,7 @@ function unbuild_ (silent) {
30
30
cb_ ( er , path . relative ( npm . root , folder ) )
31
31
}
32
32
folder = path . resolve ( folder )
33
- var base = isInside ( folder , npm . prefix ) ? npm . prefix : folder
33
+ const base = isInside ( folder , npm . prefix ) ? npm . prefix : folder
34
34
delete build . _didBuild [ folder ]
35
35
log . verbose ( 'unbuild' , folder . substr ( npm . prefix . length + 1 ) )
36
36
readJson ( path . resolve ( folder , 'package.json' ) , function ( er , pkg ) {
@@ -58,13 +58,13 @@ function rmStuff (pkg, folder, cb) {
58
58
// if it's global, and folder is in {prefix}/node_modules,
59
59
// then bins are in {prefix}/bin
60
60
// otherwise, then bins are in folder/../.bin
61
- var dir = path . dirname ( folder )
62
- var scope = path . basename ( dir )
63
- var parent = scope . charAt ( 0 ) === '@' ? path . dirname ( dir ) : dir
64
- var gnm = npm . dir
61
+ const dir = path . dirname ( folder )
62
+ const scope = path . basename ( dir )
63
+ const parent = scope . charAt ( 0 ) === '@' ? path . dirname ( dir ) : dir
64
+ const gnm = npm . dir
65
65
// gnm might be an absolute path, parent might be relative
66
66
// this checks they're the same directory regardless
67
- var top = path . relative ( gnm , parent ) === ''
67
+ const top = path . relative ( gnm , parent ) === ''
68
68
69
69
log . verbose ( 'unbuild rmStuff' , pkg . _id , 'from' , gnm )
70
70
if ( ! top ) log . verbose ( 'unbuild rmStuff' , 'in' , parent )
@@ -75,7 +75,7 @@ function rmStuff (pkg, folder, cb) {
75
75
76
76
function rmBins ( pkg , folder , parent , top , cb ) {
77
77
if ( ! pkg . bin ) return cb ( )
78
- var binRoot = top ? npm . bin : path . resolve ( parent , '.bin' )
78
+ const binRoot = top ? npm . bin : path . resolve ( parent , '.bin' )
79
79
asyncMap ( Object . keys ( pkg . bin ) , function ( b , cb ) {
80
80
if ( process . platform === 'win32' ) {
81
81
chain ( [ [ gentlyRm , path . resolve ( binRoot , b ) + '.cmd' , true , folder ] ,
@@ -98,7 +98,7 @@ function rmMans (pkg, folder, parent, top, cb) {
98
98
! npm . config . get ( 'global' ) ) {
99
99
return cb ( )
100
100
}
101
- var manRoot = path . resolve ( npm . config . get ( 'prefix' ) , 'share' , 'man' )
101
+ const manRoot = path . resolve ( npm . config . get ( 'prefix' ) , 'share' , 'man' )
102
102
log . verbose ( 'rmMans' , 'man files are' , pkg . man , 'in' , manRoot )
103
103
asyncMap ( pkg . man , function ( man , cb ) {
104
104
if ( Array . isArray ( man ) ) {
@@ -109,7 +109,7 @@ function rmMans (pkg, folder, parent, top, cb) {
109
109
110
110
function rmMan ( man ) {
111
111
log . silly ( 'rmMan' , 'preparing to remove' , man )
112
- var parseMan = man . match ( / ( .* \. ( [ 0 - 9 ] + ) ( \. g z ) ? ) $ / )
112
+ const parseMan = man . match ( / ( .* \. ( [ 0 - 9 ] + ) ( \. g z ) ? ) $ / )
113
113
if ( ! parseMan ) {
114
114
log . error (
115
115
'rmMan' , man , 'is not a valid name for a man file.' ,
@@ -119,11 +119,11 @@ function rmMans (pkg, folder, parent, top, cb) {
119
119
return cb ( )
120
120
}
121
121
122
- var stem = parseMan [ 1 ]
123
- var sxn = parseMan [ 2 ]
124
- var gz = parseMan [ 3 ] || ''
125
- var bn = path . basename ( stem )
126
- var manDest = path . join (
122
+ const stem = parseMan [ 1 ]
123
+ const sxn = parseMan [ 2 ]
124
+ const gz = parseMan [ 3 ] || ''
125
+ const bn = path . basename ( stem )
126
+ const manDest = path . join (
127
127
manRoot ,
128
128
'man' + sxn ,
129
129
( bn . indexOf ( pkg . name ) === 0 ? bn : pkg . name + '-' + bn ) + '.' + sxn + gz
0 commit comments