@@ -48,11 +48,16 @@ internals.queue = (tree) => {
4848 return topo . nodes ;
4949} ;
5050
51- internals . runScript = ( stage , { pkg, path, cwd, unsafePerm } ) => {
51+ internals . runScript = ( stage , { pkg, path, cwd, unsafePerm } , options ) => {
5252
5353 console . log ( ) ;
54- console . log ( `==========> ${ stage } ${ path || pkg . name } ...` ) ;
5554
55+ if ( options . dryRun ) {
56+ console . log ( `DRY RUN ==> ${ stage } ${ path || pkg . name } ...` ) ;
57+ return ;
58+ }
59+
60+ console . log ( `==========> ${ stage } ${ path || pkg . name } ...` ) ;
5661 return Npm . runScript ( pkg , stage , Path . join ( cwd , path ) , {
5762 dir : cwd ,
5863 unsafePerm, // @todo : find an official way to do this for top level package
@@ -95,7 +100,7 @@ internals.getLockFile = (cwd) => {
95100 }
96101} ;
97102
98- exports . run = async ( cmd = 'install' ) => {
103+ exports . run = async ( options ) => {
99104
100105 const cwd = process . cwd ( ) ;
101106 const pkg = require ( Path . join ( cwd , 'package.json' ) ) ;
@@ -116,7 +121,7 @@ exports.run = async (cmd = 'install') => {
116121 } )
117122 . filter ( ( { childPkg } ) => {
118123
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 ) ;
120125 } )
121126 . filter ( ( { path, childPkg } ) => {
122127
@@ -133,22 +138,22 @@ exports.run = async (cmd = 'install') => {
133138 return allowScripts [ name ] ;
134139 } ) ;
135140
136- await internals . runScript ( 'preinstall' , { pkg, path : '' , cwd, unsafePerm : true } ) ;
141+ await internals . runScript ( 'preinstall' , { pkg, path : '' , cwd, unsafePerm : true } , options ) ;
137142
138143 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 ) ;
140145 }
141146
142147 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 ) ;
144149 }
145150
146151 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 ) ;
148153 }
149154
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 ) ;
154159} ;
0 commit comments