Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('hashes packages', async t => {
const fromPackage = fixture('compare', 'node_modules', 'plugin')
const filename = path.join(fromPackage, 'index.js')
const hashed = await hashDependencies([
{filename, fromPackage}
])
t.deepEqual(hashed, [await packageHash(path.join(fromPackage, 'package.json'))])
})
test.before(t => {
const promises = []
for (const pkg of [
fixture('compare', 'node_modules', 'env-plugin', 'package.json'),
fixture('compare', 'node_modules', 'plugin', 'package.json'),
fixture('compare', 'node_modules', 'plugin-copy', 'package.json'),
fixture('compare', 'node_modules', 'plugin-default-opts', 'package.json'),
fixture('compare', 'node_modules', 'preset', 'package.json')
]) {
promises.push(
packageHash(pkg)
.then(hash => (hashes[pkg] = hash)))
}
for (const fp of [
fixture('compare', '.babelrc'),
fixture('compare', 'dir', 'subdir', 'extended-by-babelrc.js'),
fixture('compare', 'extended-by-virtual.json5'),
fixture('compare', 'dir', 'extended-by-virtual-foo.json5'),
fixture('compare', 'virtual.json')
]) {
promises.push(
new Promise((resolve, reject) => {
fs.readFile(fp, (err, contents) => err ? reject(err) : resolve(contents))
})
.then(md5Hex)
.then(hash => (hashes[fp] = hash)))