-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(caching): fixes a possible cache collision
- Loading branch information
Showing
2 changed files
with
35 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
// this is a template! | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const root = __dirname; | ||
const writeProcessIoTo = {{writeProcessIoTo}}; | ||
const fs = require('fs') | ||
const path = require('path') | ||
const root = __dirname | ||
const writeProcessIoTo = {{writeProcessIoTo}} | ||
|
||
exports.afterProcess = function (args, result) { | ||
// const source = args[0]; | ||
const filePath = args[1]; | ||
const relPath = path.relative(root, filePath); | ||
// const source = args[0] | ||
const filePath = args[1] | ||
const relPath = path.relative(root, filePath) | ||
if (writeProcessIoTo && filePath.startsWith(`${root}${path.sep}`)) { | ||
const dest = `${path.join(writeProcessIoTo, relPath)}.json`; | ||
const segments = relPath.split(path.sep); | ||
segments.pop(); | ||
const madeSegments = []; | ||
const dest = `${path.join(writeProcessIoTo, relPath)}.json` | ||
const segments = relPath.split(path.sep) | ||
segments.pop() | ||
const madeSegments = [] | ||
segments.forEach(segment => { | ||
madeSegments.push(segment); | ||
const p = join(writeProcessIoTo, madeSegments.join(sep)); | ||
if (!fs.existsSync(p)) fs.mkdirSync(p); | ||
}); | ||
madeSegments.push(segment) | ||
const p = path.join(writeProcessIoTo, madeSegments.join(path.sep)) | ||
if (!fs.existsSync(p)) fs.mkdirSync(p) | ||
}) | ||
fs.writeFileSync(dest, JSON.stringify({ | ||
in: args, | ||
out: result, | ||
}), 'utf8'); | ||
}), 'utf8') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters