Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (const pkgDepInfo of dependentPkgPaths) {
const pkgPath = pkgDepInfo.path;
const depHashFile = path.join(pkgPath, 'node_modules/.just', CacheFileName);
const depPackageJson = JSON.parse(fs.readFileSync(path.join(pkgPath, 'package.json'), 'utf-8'));
if (fs.existsSync(depHashFile)) {
const stat = fs.statSync(depHashFile);
timestampsByPackage[pkgDepInfo.name] = stat.mtimeMs;
} else if (depPackageJson.scripts) {
// always updated if no hash file is found for dependants
timestampsByPackage[pkgDepInfo.name] = new Date().getTime();
}
}
logger.perf('cache:getDependentHashTimestamps');
return timestampsByPackage;
}
const packageRootPath = getPackageRootPath();
const packageDeps = getPackageDeps(packageRootPath);
const lockFileHashes = getLockFileHashes();
packageDeps.files = { ...packageDeps.files, ...lockFileHashes };
const hash = {
args,
taskName,
hash: packageDeps,
dependentHashTimestamps: getDependentHashTimestamps()
};
logger.perf('cache:getHash');
return hash;
}
function collectAllDependentPaths(pkgPath: string, collected: Set = new Set()) {
mark(`collectAllDependentPaths:${pkgPath}`);
const depPaths = getDepsPaths(pkgPath);
depPaths.forEach(depPath => collected.add(depPath));
for (const depPath of depPaths) {
if (!collected.has(depPath)) {
collectAllDependentPaths(depPath.path, collected);
}
}
logger.perf(`collectAllDependentPaths:${pkgPath}`);
return collected;
}
export function findDependents() {
mark('cache:findDependents');
const results = collectAllDependentPaths(findPackageRoot());
logger.perf('cache:findDependents');
return results;
}