Skip to content

Commit

Permalink
feat: enable caching
Browse files Browse the repository at this point in the history
  • Loading branch information
dferber90 committed Sep 23, 2018
1 parent 04a62c2 commit 8a2f54f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
const fs = require("fs");
const path = require("path");
const crypto = require("crypto");
const crossSpawn = require("cross-spawn");
const stripIndent = require("common-tags/lib/stripIndent");
const THIS_FILE = fs.readFileSync(__filename);

module.exports = {
getCacheKey: (fileData, filename, configString, { instrument, rootDir }) => {
return (
crypto
.createHash("md5")
.update(THIS_FILE)
.update("\0", "utf8")
.update(fileData)
.update("\0", "utf8")
.update(path.relative(rootDir, filename))
.update("\0", "utf8")
.update(configString)
// TODO load postcssrc (the config) sync and make it part of the cache
// key
// .update("\0", "utf8")
// .update(getPostCssConfig(filename))
.update("\0", "utf8")
.update(instrument ? "instrument" : "")
.digest("hex")
);
},

process: (src, filename, config, options) => {
// The "process" function of this Jest transform must be sync,
// but postcss is async. So we spawn a sync process to do an sync
Expand Down

0 comments on commit 8a2f54f

Please sign in to comment.