Skip to content

Commit

Permalink
Merge pull request #107 from Turbo87/object-hash
Browse files Browse the repository at this point in the history
Replace `object-hash` with `hash-obj`
  • Loading branch information
Turbo87 committed Apr 28, 2019
2 parents c2568d3 + 846ab92 commit c79ef06
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env node */
'use strict';
let objectHash = require('object-hash');

const hashObj = require('hash-obj');

module.exports = {
name: 'ember-hbs-minifier',
Expand All @@ -15,7 +16,7 @@ module.exports = {
name: 'hbs-minifier-plugin',
plugin: HbsMinifierPlugin,
baseDir() { return __dirname; },
cacheKey() { return `ember-hbs-minifier-${objectHash.MD5(config)}`; }
cacheKey() { return cacheKeyForConfig(config); }
});
},

Expand All @@ -28,3 +29,12 @@ module.exports = {
this._setupPreprocessorRegistry(app);
}
};

function cacheKeyForConfig(config) {
let configHash = hashObj(config, {
encoding: 'base64',
algorithm: 'md5',
});

return `ember-hbs-minifier-${configHash}`;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
]
},
"dependencies": {
"object-hash": "1.3.1"
"hash-obj": "^1.0.0"
},
"devDependencies": {
"@ember/optional-features": "^0.7.0",
Expand Down
17 changes: 16 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4668,6 +4668,14 @@ hash-for-dep@^1.4.7, hash-for-dep@^1.5.0:
resolve "^1.10.0"
resolve-package-path "^1.0.11"

hash-obj@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/hash-obj/-/hash-obj-1.0.0.tgz#de53f9856b16f1e76f6ae04d4f9d31c31aaaea00"
integrity sha1-3lP5hWsW8edvauBNT50xwxqq6gA=
dependencies:
is-obj "^1.0.0"
sort-keys "^1.1.0"

heimdalljs-fs-monitor@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/heimdalljs-fs-monitor/-/heimdalljs-fs-monitor-0.2.2.tgz#a76d98f52dbf3aa1b7c20cebb0132e2f5eeb9204"
Expand Down Expand Up @@ -6712,7 +6720,7 @@ object-copy@^0.1.0:
define-property "^0.2.5"
kind-of "^3.0.3"

object-hash@1.3.1, object-hash@^1.3.1:
object-hash@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-1.3.1.tgz#fde452098a951cb145f039bb7d455449ddc126df"

Expand Down Expand Up @@ -7895,6 +7903,13 @@ socket.io@^2.1.0:
socket.io-client "2.2.0"
socket.io-parser "~3.3.0"

sort-keys@^1.1.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad"
integrity sha1-RBttTTRnmPG05J6JIK37oOVD+a0=
dependencies:
is-plain-obj "^1.0.0"

sort-keys@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-2.0.0.tgz#658535584861ec97d730d6cf41822e1f56684128"
Expand Down

0 comments on commit c79ef06

Please sign in to comment.