Fix file access errors when saving from cache

This commit is contained in:
Jocelyn Badgley (Twipped) 2020-02-28 10:22:53 -08:00
parent 697ee7bc8e
commit 2310f80ef3

View File

@ -3,6 +3,7 @@ const { resolve } = require('./resolve');
const log = require('fancy-log'); const log = require('fancy-log');
const Promise = require('bluebird'); const Promise = require('bluebird');
const fs = require('fs-extra'); const fs = require('fs-extra');
const path = require('path');
const LOG = { const LOG = {
new: true, new: true,
@ -33,6 +34,7 @@ module.exports = exports = async function process (tasks, cache) {
if (status.mode === 'cached') { if (status.mode === 'cached') {
result = status.cache; result = status.cache;
await fs.ensureDir(path.dirname(resolve('dist', output)));
await fs.writeFile(resolve('dist', output), result); await fs.writeFile(resolve('dist', output), result);
await cache.touch(task, lastSeen); await cache.touch(task, lastSeen);
} else { } else {