diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
commit | cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch) | |
tree | 92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/hullabaloo-config-manager/lib/hashSources.js | |
parent | 3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff) |
remove node_modules
Diffstat (limited to 'node_modules/hullabaloo-config-manager/lib/hashSources.js')
-rw-r--r-- | node_modules/hullabaloo-config-manager/lib/hashSources.js | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/node_modules/hullabaloo-config-manager/lib/hashSources.js b/node_modules/hullabaloo-config-manager/lib/hashSources.js deleted file mode 100644 index e48660ea9..000000000 --- a/node_modules/hullabaloo-config-manager/lib/hashSources.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict' - -const path = require('path') - -const dotProp = require('dot-prop') -const md5Hex = require('md5-hex') - -const errors = require('./errors') -const readSafe = require('./readSafe') - -function hashSource (source, cache) { - if (cache && cache.sourceHashes && cache.sourceHashes.has(source)) { - return cache.sourceHashes.get(source) - } - - const basename = path.basename(source) - const parts = basename.split('#') - const filename = parts[0] - const filepath = path.join(path.dirname(source), filename) - - const pkgAccessor = filename === 'package.json' - ? parts[1] || 'babel' - : null - - const promise = readSafe(filepath, cache) - .then(contents => { - if (!contents) throw new errors.NoSourceFileError(source) - - if (!pkgAccessor) { - return md5Hex(contents) - } - - const json = JSON.parse(contents.toString('utf8')) - const value = dotProp.get(json, pkgAccessor) || {} - return md5Hex(JSON.stringify(value)) - }) - - if (cache && cache.sourceHashes) { - cache.sourceHashes.set(source, promise) - } - return promise -} - -function hashSources (sources, fixedHashes, cache) { - const promises = sources.map(item => { - if (fixedHashes && fixedHashes.has(item.source)) return fixedHashes.get(item.source) - return hashSource(item.source, cache) - }) - return Promise.all(promises) -} -module.exports = hashSources |