packages/cli: remove output dir before building with cache

This commit is contained in:
Patrik Oldsberg
2020-04-07 10:06:00 +02:00
parent 08a5023ad4
commit f5ddb99105
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import fs from 'fs-extra';
import { Command } from 'commander';
import { run } from 'helpers/run';
import { Cache } from './cache';
@@ -31,6 +32,7 @@ export async function withCache(
const key = await Cache.readInputKey(options.inputs);
if (!key) {
print('input directory is dirty, skipping cache');
await fs.remove(options.output);
await buildFunc();
return;
}
@@ -49,6 +51,7 @@ export async function withCache(
}
print('cache miss, need to build');
await fs.remove(options.output);
await buildFunc();
await cacheResult.archive(options.output, options.maxCacheEntries);