@@ -48,11 +48,16 @@ internals.queue = (tree) => {
48
48
return topo . nodes ;
49
49
} ;
50
50
51
- internals . runScript = ( stage , { pkg, path, cwd, unsafePerm } ) => {
51
+ internals . runScript = ( stage , { pkg, path, cwd, unsafePerm } , options ) => {
52
52
53
53
console . log ( ) ;
54
- console . log ( `==========> ${ stage } ${ path || pkg . name } ...` ) ;
55
54
55
+ if ( options . dryRun ) {
56
+ console . log ( `DRY RUN ==> ${ stage } ${ path || pkg . name } ...` ) ;
57
+ return ;
58
+ }
59
+
60
+ console . log ( `==========> ${ stage } ${ path || pkg . name } ...` ) ;
56
61
return Npm . runScript ( pkg , stage , Path . join ( cwd , path ) , {
57
62
dir : cwd ,
58
63
unsafePerm, // @todo : find an official way to do this for top level package
@@ -95,7 +100,7 @@ internals.getLockFile = (cwd) => {
95
100
}
96
101
} ;
97
102
98
- exports . run = async ( cmd = 'install' ) => {
103
+ exports . run = async ( options ) => {
99
104
100
105
const cwd = process . cwd ( ) ;
101
106
const pkg = require ( Path . join ( cwd , 'package.json' ) ) ;
@@ -116,7 +121,7 @@ exports.run = async (cmd = 'install') => {
116
121
} )
117
122
. filter ( ( { childPkg } ) => {
118
123
119
- return childPkg . scripts && ( childPkg . scripts [ cmd ] || childPkg . scripts [ `pre ${ cmd } ` ] || childPkg . scripts [ `post ${ childPkg } ` ] ) ;
124
+ return childPkg . scripts && ( childPkg . scripts . install || childPkg . scripts . preinstall || childPkg . scripts . postinstall ) ;
120
125
} )
121
126
. filter ( ( { path, childPkg } ) => {
122
127
@@ -133,22 +138,22 @@ exports.run = async (cmd = 'install') => {
133
138
return allowScripts [ name ] ;
134
139
} ) ;
135
140
136
- await internals . runScript ( 'preinstall' , { pkg, path : '' , cwd, unsafePerm : true } ) ;
141
+ await internals . runScript ( 'preinstall' , { pkg, path : '' , cwd, unsafePerm : true } , options ) ;
137
142
138
143
for ( const { path, childPkg } of allowedScripts ) {
139
- await internals . runScript ( 'preinstall' , { pkg : childPkg , path, cwd } ) ;
144
+ await internals . runScript ( 'preinstall' , { pkg : childPkg , path, cwd } , options ) ;
140
145
}
141
146
142
147
for ( const { path, childPkg } of allowedScripts ) {
143
- await internals . runScript ( 'install' , { pkg : childPkg , path, cwd } ) ;
148
+ await internals . runScript ( 'install' , { pkg : childPkg , path, cwd } , options ) ;
144
149
}
145
150
146
151
for ( const { path, childPkg } of allowedScripts ) {
147
- await internals . runScript ( 'postinstall' , { pkg : childPkg , path, cwd } ) ;
152
+ await internals . runScript ( 'postinstall' , { pkg : childPkg , path, cwd } , options ) ;
148
153
}
149
154
150
- await internals . runScript ( 'install' , { pkg, path : '' , cwd, unsafePerm : true } ) ;
151
- await internals . runScript ( 'postinstall' , { pkg, path : '' , cwd, unsafePerm : true } ) ;
152
- await internals . runScript ( 'prepublish' , { pkg, path : '' , cwd, unsafePerm : true } ) ;
153
- await internals . runScript ( 'prepare' , { pkg, path : '' , cwd, unsafePerm : true } ) ;
155
+ await internals . runScript ( 'install' , { pkg, path : '' , cwd, unsafePerm : true } , options ) ;
156
+ await internals . runScript ( 'postinstall' , { pkg, path : '' , cwd, unsafePerm : true } , options ) ;
157
+ await internals . runScript ( 'prepublish' , { pkg, path : '' , cwd, unsafePerm : true } , options ) ;
158
+ await internals . runScript ( 'prepare' , { pkg, path : '' , cwd, unsafePerm : true } , options ) ;
154
159
} ;
0 commit comments