Skip to content

Commit cbd4634

Browse files
paulkaplanRay Schamp
authored andcommitted
fix(dependencies): Replace crypto with js-md5 package
1 parent 9fce982 commit cbd4634

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"eslint-config-scratch": "3.1.0",
3737
"eslint-plugin-react": "6.9.0",
3838
"file-loader": "0.9.0",
39+
"js-md5": "0.6.1",
3940
"json": "^9.0.4",
4041
"json-loader": "0.5.4",
4142
"localforage": "1.5.0",

src/BuiltinHelper.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const crypto = require('crypto');
1+
const md5 = require('js-md5');
22

33
const Asset = require('./Asset');
44
const AssetType = require('./AssetType');
@@ -99,9 +99,7 @@ class BuiltinHelper extends Helper {
9999
if (id) {
100100
if (this.assets.hasOwnProperty(id) && assetType.immutable) return id;
101101
} else if (assetType.immutable) {
102-
const hash = crypto.createHash('md5');
103-
hash.update(data);
104-
id = hash.digest('hex');
102+
id = md5(data);
105103
}
106104
this.assets[id] = {
107105
type: assetType,

test/integration/download-known-assets.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const crypto = require('crypto');
1+
const md5 = require('js-md5');
22
const test = require('tap').test;
33

44
const ScratchStorage = require('../../dist/node/scratch-storage');
@@ -93,9 +93,7 @@ test('load', t => {
9393
t.ok(asset.data.length);
9494

9595
if (assetInfo.md5) {
96-
const hash = crypto.createHash('md5');
97-
hash.update(asset.data);
98-
t.strictEqual(hash.digest('hex'), assetInfo.md5);
96+
t.strictEqual(md5(asset.data), assetInfo.md5);
9997
}
10098
};
10199
for (var i = 0; i < testAssets.length; ++i) {

test/unit/load-default-assets.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const crypto = require('crypto');
1+
const md5 = require('js-md5');
22
const test = require('tap').test;
33

44
const ScratchStorage = require('../../dist/node/scratch-storage');
@@ -30,10 +30,7 @@ test('load', t => {
3030
t.strictEqual(asset.assetId, id);
3131
t.strictEqual(asset.assetType, assetType);
3232
t.ok(asset.data.length);
33-
34-
const hash = crypto.createHash('md5');
35-
hash.update(asset.data);
36-
t.strictEqual(hash.digest('hex'), id);
33+
t.strictEqual(md5(asset.data), id);
3734
};
3835
for (var i = 0; i < defaultAssetTypes.length; ++i) {
3936
const assetType = defaultAssetTypes[i];

0 commit comments

Comments
 (0)