node_modules is stale -> ignore node-version changes

This commit is contained in:
Henning Dieterichs
2026-03-20 21:21:34 +01:00
committed by Henning Dieterichs
parent 5f094293b4
commit c9335c2873
2 changed files with 12 additions and 7 deletions

View File

@@ -112,7 +112,7 @@ export class NpmUpToDateFeature extends vscode.Disposable {
}
try {
const script = path.join(workspaceRoot, 'build', 'npm', 'installStateHash.ts');
const output = cp.execFileSync(process.execPath, [script], {
const output = cp.execFileSync(process.execPath, [script, '--ignore-node-version'], {
cwd: workspaceRoot,
timeout: 10_000,
encoding: 'utf8',

View File

@@ -87,7 +87,7 @@ function hashContent(content: string): string {
return hash.digest('hex');
}
export function computeState(): PostinstallState {
export function computeState(options?: { ignoreNodeVersion?: boolean }): PostinstallState {
const fileHashes: Record<string, string> = {};
for (const filePath of collectInputFiles()) {
const key = path.relative(root, filePath);
@@ -97,7 +97,7 @@ export function computeState(): PostinstallState {
// file may not be readable
}
}
return { nodeVersion: process.versions.node, fileHashes };
return { nodeVersion: options?.ignoreNodeVersion ? '' : process.versions.node, fileHashes };
}
export function computeContents(): Record<string, string> {
@@ -141,18 +141,23 @@ export function readSavedContents(): Record<string, string> | undefined {
// When run directly, output state as JSON for tooling (e.g. the vscode-extras extension).
if (import.meta.filename === process.argv[1]) {
if (process.argv[2] === '--normalize-file') {
const filePath = process.argv[3];
const args = new Set(process.argv.slice(2));
if (args.has('--normalize-file')) {
const filePath = process.argv[process.argv.indexOf('--normalize-file') + 1];
if (!filePath) {
process.exit(1);
}
process.stdout.write(normalizeFileContent(filePath));
} else {
const ignoreNodeVersion = args.has('--ignore-node-version');
const current = computeState({ ignoreNodeVersion });
const saved = readSavedState();
console.log(JSON.stringify({
root,
stateContentsFile,
current: computeState(),
saved: readSavedState(),
current,
saved: saved && ignoreNodeVersion ? { nodeVersion: '', fileHashes: saved.fileHashes } : saved,
files: [...collectInputFiles(), stateFile],
}));
}