@@ -4,7 +4,7 @@ import * as fs from "fs-extra"
44import { releaseAllMutexes } from "gatsby-core-utils/mutex"
55import md5File from "md5-file"
66import crypto from "crypto"
7- import del from "del "
7+ import { globby as glob } from "globby "
88import path from "path"
99import telemetry from "gatsby-telemetry"
1010
@@ -284,12 +284,18 @@ export async function initialize({
284284 }
285285 )
286286 activity . start ( )
287- await del ( [
288- `public/**/*.{html,css}` ,
289- `!public/page-data/**/*` ,
290- `!public/static` ,
291- `!public/static/**/*.{html,css}` ,
292- ] )
287+ const files = await glob (
288+ [
289+ `public/**/*.{html,css}` ,
290+ `!public/page-data/**/*` ,
291+ `!public/static` ,
292+ `!public/static/**/*.{html,css}` ,
293+ ] ,
294+ {
295+ cwd : program . directory ,
296+ }
297+ )
298+ await Promise . all ( files . map ( file => fs . remove ( file ) ) )
293299 activity . end ( )
294300 }
295301
@@ -429,28 +435,30 @@ export async function initialize({
429435
430436 const deleteGlobs = [
431437 // By default delete all files & subdirectories
432- `${ cacheDirectory } /**` ,
433- `!${ cacheDirectory } /data` ,
434- `${ cacheDirectory } /data/**` ,
435- `!${ cacheDirectory } /data/gatsby-core-utils/` ,
436- `!${ cacheDirectory } /data/gatsby-core-utils/**` ,
437- `!${ cacheDirectory } /compiled` ,
438+ `.cache/**` ,
439+ `.cache/data/**` ,
440+ `!.cache/data/gatsby-core-utils/**` ,
441+ `!.cache/compiled` ,
438442 ]
439443
440444 if ( process . env . GATSBY_EXPERIMENTAL_PRESERVE_FILE_DOWNLOAD_CACHE ) {
441445 // Stop the caches directory from being deleted, add all sub directories,
442446 // but remove gatsby-source-filesystem
443- deleteGlobs . push ( `!${ cacheDirectory } /caches` )
444- deleteGlobs . push ( `${ cacheDirectory } /caches/*` )
445- deleteGlobs . push ( `!${ cacheDirectory } /caches/gatsby-source-filesystem` )
447+ deleteGlobs . push ( `!.cache /caches` )
448+ deleteGlobs . push ( `.cache /caches/*` )
449+ deleteGlobs . push ( `!.cache /caches/gatsby-source-filesystem` )
446450 }
447451
448452 if ( process . env . GATSBY_EXPERIMENTAL_PRESERVE_WEBPACK_CACHE ) {
449453 // Add webpack
450- deleteGlobs . push ( `!${ cacheDirectory } /webpack` )
454+ deleteGlobs . push ( `!.cache /webpack` )
451455 }
452456
453- await del ( deleteGlobs )
457+ const files = await glob ( deleteGlobs , {
458+ cwd : program . directory ,
459+ } )
460+
461+ await Promise . all ( files . map ( file => fs . remove ( file ) ) )
454462 } catch ( e ) {
455463 reporter . error ( `Failed to remove .cache files.` , e )
456464 }
0 commit comments