3030 */
3131class Processor
3232{
33+ const MODE_DEPLOYMENT = 'deployment ' ;
3334 /**
3435 * @var Io
3536 */
@@ -178,7 +179,9 @@ public function process(\Iterator $assets): bool
178179 throw new \Error ('Invalid root config. ' );
179180 }
180181
181- $ toWipe = [];
182+ $ globalWipeNodeModules = $ this ->isWipeNodeModulesEnabledGlobally ();
183+ $ globalCleanPackageManagerCache = $ this ->isCleanPackageManagerCacheEnabledGlobally ();
184+
182185 $ stopOnFailure = $ rootConfig ->stopOnFailure ();
183186 $ return = true ;
184187 $ processManager = $ this ->parallelManager ;
@@ -195,7 +198,7 @@ public function process(\Iterator $assets): bool
195198 continue ;
196199 }
197200
198- if ($ this -> passedArguments -> forceDeleteNodeModules () ) {
201+ if ($ globalWipeNodeModules ) {
199202 $ shouldWipe = true ;
200203 }
201204
@@ -335,9 +338,9 @@ public function process(\Iterator $assets): bool
335338 $ onBatchCompletedCallback = function (
336339 array $ groups ,
337340 int $ batchNumber
338- ): void {
341+ ) use ( $ globalCleanPackageManagerCache ) : void {
339342 $ this ->io ->write (sprintf ("Batch %d completed " , $ batchNumber ));
340- if ($ this -> passedArguments -> clearPackageManagerCache () ) {
343+ if ($ globalCleanPackageManagerCache ) {
341344 $ this ->io ->writeComment ('Clearing package manager cache ' );
342345 $ result = $ this ->executor ->execute (
343346 'npm cache clear --force ' ,
@@ -361,6 +364,18 @@ public function process(\Iterator $assets): bool
361364 return true ;
362365 }
363366
367+ private function isWipeNodeModulesEnabledGlobally (): bool
368+ {
369+ return $ this ->passedArguments ->mode () === static ::MODE_DEPLOYMENT
370+ || $ this ->passedArguments ->forceDeleteNodeModules ();
371+ }
372+
373+ private function isCleanPackageManagerCacheEnabledGlobally (): bool
374+ {
375+ return $ this ->passedArguments ->mode () === static ::MODE_DEPLOYMENT
376+ || $ this ->passedArguments ->clearPackageManagerCache ();
377+ }
378+
364379 /**
365380 * @param Asset $asset
366381 * @param RootConfig $root
0 commit comments