diff --git a/packages/cli/src/commands/build-cache/cache.ts b/packages/cli/src/commands/build-cache/cache.ts index d5ed39e148..da653a0331 100644 --- a/packages/cli/src/commands/build-cache/cache.ts +++ b/packages/cli/src/commands/build-cache/cache.ts @@ -16,7 +16,7 @@ import fs from 'fs-extra'; import { resolve as resolvePath, relative as relativePath } from 'path'; -import { runPlain } from '../../helpers/run'; +import { runPlain, runCheck } from '../../helpers/run'; import { Options } from './options'; import { extractArchive, createArchive } from './archive'; @@ -47,9 +47,10 @@ export class Cache { const location = resolvePath(options.cacheDir, repoPath); // Make sure we don't have any uncommitted changes to the input, in that case we consider the cache to be missing - try { - // await exec(`git diff --quiet HEAD -- ${options.inputs.join(' ')}`); - } catch (error) { + const noChanges = await runCheck( + `git diff --quiet HEAD -- ${options.inputs.join(' ')}`, + ); + if (!noChanges) { return new Cache(); } diff --git a/packages/cli/src/helpers/run.ts b/packages/cli/src/helpers/run.ts index 6a1376baf8..cbeb2c080c 100644 --- a/packages/cli/src/helpers/run.ts +++ b/packages/cli/src/helpers/run.ts @@ -62,6 +62,15 @@ export async function runPlain(cmd: string) { } } +export async function runCheck(cmd: string): Promise { + try { + await exec(cmd); + return true; + } catch (error) { + return false; + } +} + export async function waitForExit( child: ChildProcess & { exitCode?: number }, name?: string,