Skip to content

Commit

Permalink
fix(gatsby): better heuristic for automatic cache purging (#27682)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladar authored Oct 27, 2020
1 parent 2da94bf commit a5665d2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/gatsby/src/services/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,11 @@ export async function initialize({
}
const cacheDirectory = `${program.directory}/.cache`
const publicDirectory = `${program.directory}/public`

// .cache directory exists in develop at this point
// so checking for .cache/json as a heuristic (could be any expected file)
const cacheIsCorrupt =
fs.existsSync(cacheDirectory) && !fs.existsSync(publicDirectory)
fs.existsSync(`${cacheDirectory}/json`) && !fs.existsSync(publicDirectory)

if (cacheIsCorrupt) {
reporter.info(reporter.stripIndent`
Expand Down

0 comments on commit a5665d2

Please sign in to comment.