@@ -62,13 +62,13 @@ const shouldDeleteYalc = allFlag || yalcFlag;
6262
6363const EXT_DIR_PATH = path . join ( __dirname , '..' ) ;
6464const CORE_DIR_PATH = path . join ( EXT_DIR_PATH , '..' , 'paranext-core' ) ;
65- const SKIP_DIRS = new Set ( [ '.yalc' , 'dev-appdata' , 'dev-packages' , 'lib' ] ) ;
65+ const SKIP_DIRS = new Set ( [ '.yalc' , 'dev-appdata' , 'dev-packages' , 'lib' , 'node_modules' ] ) ;
6666
6767const BUILD_PATHS = [ ] ;
6868if ( shouldDeleteBuild ) {
6969 // Add core build output subdirectories to `BUILD_PATHS`
70- BUILD_PATHS . push ( ...findDirsNamed ( CORE_DIR_PATH , 'dist' , SKIP_DIRS ) ) ;
71- BUILD_PATHS . push ( ...findDirsNamed ( CORE_DIR_PATH , 'temp-build' , SKIP_DIRS ) ) ;
70+ BUILD_PATHS . push ( ...findNamed ( CORE_DIR_PATH , 'dist' , SKIP_DIRS ) ) ;
71+ BUILD_PATHS . push ( ...findNamed ( CORE_DIR_PATH , 'temp-build' , SKIP_DIRS ) ) ;
7272}
7373
7474const CORE_PATHS = [ path . join ( CORE_DIR_PATH , 'dev-appdata' ) ] ;
@@ -106,7 +106,7 @@ const NPM_PATHS = [
106106] ;
107107if ( shouldDeleteNpm ) {
108108 // Find core `node_modules` subdirectories and add them to `NPM_PATHS`
109- NPM_PATHS . push ( ...findDirsNamed ( CORE_DIR_PATH , 'node_modules' , SKIP_DIRS ) ) ;
109+ NPM_PATHS . push ( ...findNamed ( CORE_DIR_PATH , 'node_modules' , SKIP_DIRS ) ) ;
110110}
111111
112112const TEST_PATHS = [ path . join ( EXT_DIR_PATH , 'coverage' ) , path . join ( EXT_DIR_PATH , '.eslintcache' ) ] ;
@@ -125,19 +125,18 @@ const YALC_PATHS = [
125125 * @param {Set<string> } skipDirs - Directory names to skip entirely
126126 * @returns {string[] } Absolute paths of every matching directory found
127127 */
128- function findDirsNamed ( corePath , targetDir , skipDirs ) {
128+ function findNamed ( corePath , target , skipDirs ) {
129129 let entries ;
130130 try {
131131 entries = fs . readdirSync ( corePath , { withFileTypes : true } ) ;
132132 } catch {
133133 return [ ] ;
134134 }
135135 return entries
136- . filter ( ( entry ) => entry . isDirectory ( ) && ! skipDirs . has ( entry . name ) )
136+ . filter ( ( entry ) => entry . name === target || ( entry . isDirectory ( ) && ! skipDirs . has ( entry . name ) ) )
137137 . flatMap ( ( entry ) => {
138138 const fullPath = path . join ( corePath , entry . name ) ;
139- if ( entry . name === targetDir ) return [ fullPath ] ;
140- return findDirsNamed ( fullPath , targetDir , skipDirs ) ;
139+ return entry . name === target ? [ fullPath ] : findNamed ( fullPath , target , skipDirs ) ;
141140 } ) ;
142141}
143142
0 commit comments