@@ -4,32 +4,53 @@ const rimraf = require('rimraf');
44
55const utils = require ( '../utils' ) ;
66
7- const baseThingsToClean = [ 'dist' ] ;
7+ const baseThingsToClean = [ 'coverage/' , 'dist/' , 'lerna-debug.log' , 'yarn-error.log' ] ;
8+
9+ const lockFilesToClean = [ 'package-lock.json' , 'yarn.lock' ] ;
10+
11+ const nodeModulesToClean = [ 'node_modules/' ] ;
812
913const args = process . argv . slice ( 2 ) ;
1014let dryRun = false ;
15+ let lockFiles = false ;
16+ let nodeModules = false ;
1117
1218if ( args . length ) {
1319 args . forEach ( ( arg ) => {
1420 if ( arg === '--dry-run' ) {
1521 console . info ( chalk `{black.bgWhite Doing a dry run. No changes will be made.\n}` ) ;
1622 dryRun = true ;
1723 }
24+
25+ if ( arg === '--lock-files' ) {
26+ lockFiles = true ;
27+ }
28+
29+ if ( arg === '--node-modules' ) {
30+ nodeModules = true ;
31+ }
1832 } ) ;
1933}
2034
21- const projectBasePath = utils . getProjectPath ( ) ;
35+ const projectPaths = [ utils . getProjectPath ( ) ] . concat ( utils . getExplicitProjectPaths ( ) ) ;
2236
2337const extraToClean = utils . getConfigFromPackageJson ( 'extraToClean' , [ ] ) ;
2438
25- const toClean = Array . prototype . concat ( baseThingsToClean , extraToClean ) ;
39+ const toClean = Array . prototype . concat (
40+ baseThingsToClean ,
41+ lockFiles && lockFilesToClean ,
42+ nodeModules && nodeModulesToClean ,
43+ extraToClean ,
44+ ) ;
2645
27- toClean . forEach ( ( thePathToClean ) => {
28- const pathToClean = path . join ( projectBasePath , thePathToClean ) ;
46+ projectPaths . forEach ( ( projectPath ) => {
47+ toClean . forEach ( ( thePathToClean ) => {
48+ const pathToClean = path . join ( projectPath , thePathToClean ) ;
2949
30- console . info ( chalk `{white.bgRed Deleting} {black.bgWhite ${ pathToClean } }` ) ;
50+ console . info ( chalk `{white.bgRed Deleting} {black.bgWhite ${ pathToClean } }` ) ;
3151
32- if ( ! dryRun ) {
33- rimraf . sync ( pathToClean ) ;
34- }
52+ if ( ! dryRun ) {
53+ rimraf . sync ( pathToClean ) ;
54+ }
55+ } ) ;
3556} ) ;
0 commit comments