From 4751c8f215ba0b033500f93543b21f87e1c3e8dc Mon Sep 17 00:00:00 2001 From: "Jocelyn Badgley (Twipped)" Date: Thu, 27 Feb 2020 20:41:18 -0800 Subject: [PATCH] Skip cache if a task is a copy or says to skip cache --- gulp/content/cache.js | 17 ++++++++++++++--- gulp/content/evaluate.js | 1 + gulp/content/file.js | 1 + gulp/content/svg.js | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gulp/content/cache.js b/gulp/content/cache.js index 2d42a33..c21de80 100644 --- a/gulp/content/cache.js +++ b/gulp/content/cache.js @@ -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 }; } diff --git a/gulp/content/evaluate.js b/gulp/content/evaluate.js index e1ea249..8c157af 100644 --- a/gulp/content/evaluate.js +++ b/gulp/content/evaluate.js @@ -11,6 +11,7 @@ const LOG = { rebuild: true, cached: false, copy: false, + silent: false, }; module.exports = exports = async function process (tasks, cache) { diff --git a/gulp/content/file.js b/gulp/content/file.js index e7911da..e305da5 100644 --- a/gulp/content/file.js +++ b/gulp/content/file.js @@ -70,6 +70,7 @@ module.exports = exports = class File { input: this.input, output: this.out, action: actions.copy, + nocache: true, } ]; } diff --git a/gulp/content/svg.js b/gulp/content/svg.js index 84e0565..7da8eb7 100644 --- a/gulp/content/svg.js +++ b/gulp/content/svg.js @@ -9,6 +9,7 @@ module.exports = exports = async function svgIcons () { input: f, output: 'images/' + f, action: actions.copy, + nocache: true, })); return tasks;