Skip cache if a task is a copy or says to skip cache

This commit is contained in:
Jocelyn Badgley (Twipped) 2020-02-27 20:41:18 -08:00
parent e95f2cf3db
commit 4751c8f215
4 changed files with 17 additions and 3 deletions

View File

@ -85,6 +85,11 @@ module.exports = exports = class Manifest {
mode: 'new',
};
if (task.nocache) {
result.mode = 'silent';
return result;
}
const [ iTime, oTime, cTime, iRev ] = await Promise.all([
local && this.stat(input),
this.stat(output),
@ -129,6 +134,9 @@ module.exports = exports = class Manifest {
}
async touch (task, lastSeen = new Date()) {
if (task.nocache || task.action.name) return null;
const hash = this.hash(task);
const { input, output } = task;
const local = !task.input.includes('://');
@ -159,6 +167,7 @@ module.exports = exports = class Manifest {
async set (task, result, lastSeen = new Date()) {
const hash = this.hash(task);
const { input, output } = task;
const nocache = task.nocache || task.action.name === 'copy';
const ext = path.extname(task.output);
const local = !task.input.includes('://');
const cached = path.join(CACHE, hash + ext);
@ -167,7 +176,7 @@ module.exports = exports = class Manifest {
const [ iTime, iRev ] = await Promise.all([
local && this.stat(input),
local && this.compareBy.inputRev && this.revFile(input),
result && fs.writeFile(resolve(cached), result),
result && !nocache && fs.writeFile(resolve(cached), result),
]);
const record = {
@ -184,8 +193,10 @@ module.exports = exports = class Manifest {
};
this.revManifest[output] = record.revPath;
this.manifest[hash] = record;
await this.writeManifest();
if (!nocache) {
this.manifest[hash] = record;
await this.writeManifest();
}
return { ...record };
}

View File

@ -11,6 +11,7 @@ const LOG = {
rebuild: true,
cached: false,
copy: false,
silent: false,
};
module.exports = exports = async function process (tasks, cache) {

View File

@ -70,6 +70,7 @@ module.exports = exports = class File {
input: this.input,
output: this.out,
action: actions.copy,
nocache: true,
} ];
}

View File

@ -9,6 +9,7 @@ module.exports = exports = async function svgIcons () {
input: f,
output: 'images/' + f,
action: actions.copy,
nocache: true,
}));
return tasks;