-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
The original writeHash method takes an optional string for the hash.
However, the method that gets returned is writeHash.bind(null, result.hash)
As a result, as a workaround for #16 , I'm unable to write a custom hash.
My suggestion is to move the writeHash method to just below the const result = and change it to
const writeHash = (hash: string | undefined = result.hash) =>
hash && fs.writeFileSync(packageHashPath, hash, {});This would allow me to use a concatenated hash for multiple files, like so:
/** @type {import('package-changed/types')} */
const { isPackageChanged } = require('package-changed');
/** @type {import('child_process')} */
const { execSync } = require('node:child_process');
(async () => {
const { oldHash, hash: rootHash, writeHash } = await isPackageChanged({ noHashFile: true });
const { hash: nextjsHash } = await isPackageChanged({ noHashFile: true, cwd: './nextjs' });
const newHash = `${rootHash}${nextjsHash}`;
if (newHash !== oldHash) {
console.log("Package changed. Running 'rm -f .eslintcache && pnpm install'.");
// dependencies in a package.json have changed since last run
execSync('rm -f .eslintcache');
execSync('pnpm install');
writeHash(newHash);
}
})();I will open a PR for this shortly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels