Skip to content
This repository was archived by the owner on Oct 27, 2020. It is now read-only.

Commit bcbfbfc

Browse files
committed
fix: minor changes for deps
1 parent 1201db0 commit bcbfbfc

File tree

3 files changed

+15
-24
lines changed

3 files changed

+15
-24
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ const crypto = require('crypto');
9595
const BUILD_CACHE_TIMEOUT = 24 * 3600; // 1 day
9696

9797
function digest(str) {
98-
return crypto
99-
.createHash('md5')
100-
.update(str)
101-
.digest('hex');
98+
return crypto.createHash('md5').update(str).digest('hex');
10299
}
103100

104101
// Generate own cache key

src/index.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/* eslint-disable
2-
import/order
3-
*/
1+
/* eslint-disable import/order */
42
const fs = require('fs');
53
const os = require('os');
64
const v8 = require('v8');
@@ -169,7 +167,7 @@ function pitch(remainingRequest, prevRequest, dataInput) {
169167

170168
const callback = this.async();
171169
const data = dataInput;
172-
const { emitFile } = this;
170+
const emitFile = this.emitFile.bind(this);
173171

174172
data.remainingRequest = remainingRequest;
175173
data.cacheKey = cacheKeyFn(options, data.remainingRequest);
@@ -270,10 +268,7 @@ function pitch(remainingRequest, prevRequest, dataInput) {
270268
}
271269

272270
function digest(str) {
273-
return crypto
274-
.createHash('md5')
275-
.update(str)
276-
.digest('hex');
271+
return crypto.createHash('md5').update(str).digest('hex');
277272
}
278273

279274
const directories = new Set();
@@ -286,16 +281,15 @@ function write(key, data, callback) {
286281
// for performance skip creating directory
287282
fs.writeFile(key, content, callback);
288283
} else {
289-
mkdirp(dirname, (mkdirErr) => {
290-
if (mkdirErr) {
284+
mkdirp(dirname).then(
285+
() => {
286+
directories.add(dirname);
287+
fs.writeFile(key, content, callback);
288+
},
289+
(mkdirErr) => {
291290
callback(mkdirErr);
292-
return;
293291
}
294-
295-
directories.add(dirname);
296-
297-
fs.writeFile(key, content, callback);
298-
});
292+
);
299293
}
300294
}
301295

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`validate options error (pitch) 1`] = `
4-
"Invalid options object. Cache Loader (Pitch) has been initialised using an options object that does not match the API schema.
4+
"Invalid options object. Cache Loader (Pitch) has been initialized using an options object that does not match the API schema.
55
- options.cacheIdentifier should be a string.
66
-> Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders (used for default read/write implementation)."
77
`;
88

99
exports[`validate options error 1`] = `
10-
"Invalid options object. Cache Loader has been initialised using an options object that does not match the API schema.
10+
"Invalid options object. Cache Loader has been initialized using an options object that does not match the API schema.
1111
- options.cacheIdentifier should be a string.
1212
-> Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders (used for default read/write implementation)."
1313
`;
1414

1515
exports[`validate options unknown (pitch) 1`] = `
16-
"Invalid options object. Cache Loader (Pitch) has been initialised using an options object that does not match the API schema.
16+
"Invalid options object. Cache Loader (Pitch) has been initialized using an options object that does not match the API schema.
1717
- options has an unknown property 'unknown'. These properties are valid:
1818
object { cacheAddedFiles?, cacheContext?, cacheKey?, cacheIdentifier?, cacheDirectory?, compare?, precision?, read?, readOnly?, write? }"
1919
`;
2020
2121
exports[`validate options unknown 1`] = `
22-
"Invalid options object. Cache Loader has been initialised using an options object that does not match the API schema.
22+
"Invalid options object. Cache Loader has been initialized using an options object that does not match the API schema.
2323
- options has an unknown property 'unknown'. These properties are valid:
2424
object { cacheAddedFiles?, cacheContext?, cacheKey?, cacheIdentifier?, cacheDirectory?, compare?, precision?, read?, readOnly?, write? }"
2525
`;

0 commit comments

Comments
 (0)