cli/commands/build-cache: enable dirty check

This commit is contained in:
Patrik Oldsberg
2020-03-27 15:07:21 +01:00
parent b87a760dd5
commit 3ca00be607
2 changed files with 14 additions and 4 deletions
@@ -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();
}
+9
View File
@@ -62,6 +62,15 @@ export async function runPlain(cmd: string) {
}
}
export async function runCheck(cmd: string): Promise<boolean> {
try {
await exec(cmd);
return true;
} catch (error) {
return false;
}
}
export async function waitForExit(
child: ChildProcess & { exitCode?: number },
name?: string,