aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ava/lib/caching-precompiler.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-27 19:33:54 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-27 19:34:16 +0100
commit0e6de2c31dbf8c21277481f112e99c52b913940f (patch)
tree91789032de3b8eec9d789acd1323f25fc5d08422 /node_modules/ava/lib/caching-precompiler.js
parentceda0da31ad542c598c68146ae0712ca03df3d71 (diff)
node_modules
Diffstat (limited to 'node_modules/ava/lib/caching-precompiler.js')
-rw-r--r--node_modules/ava/lib/caching-precompiler.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/node_modules/ava/lib/caching-precompiler.js b/node_modules/ava/lib/caching-precompiler.js
index 937309bf0..f6e5e47c3 100644
--- a/node_modules/ava/lib/caching-precompiler.js
+++ b/node_modules/ava/lib/caching-precompiler.js
@@ -33,6 +33,7 @@ class CachingPrecompiler {
this.fileHashes = {};
this.transform = this._createTransform();
}
+
precompileFile(filePath) {
if (!this.fileHashes[filePath]) {
const source = stripBomBuf(fs.readFileSync(filePath));
@@ -41,11 +42,13 @@ class CachingPrecompiler {
return this.fileHashes[filePath];
}
+
// Conditionally called by caching-transform when precompiling is required
_init() {
this.babel = require('babel-core');
return this._transform;
}
+
_transform(code, filePath, hash) {
code = code.toString();
@@ -79,6 +82,7 @@ class CachingPrecompiler {
return `${result.code}\n${comment}`;
}
+
_createTransform() {
const salt = packageHash.sync([
require.resolve('../package.json'),
@@ -93,6 +97,7 @@ class CachingPrecompiler {
ext: '.js'
});
}
+
_generateHash(code, filePath, salt) {
const hash = md5Hex([code, filePath, salt]);
this.fileHashes[filePath] = hash;