Skip to content

Commit 27c3ee0

Browse files
authored
[Fix] VSIX validation on windows when cleaningup residual (#761)
1 parent ff67d5d commit 27c3ee0

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

scripts/validate-tools.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const TOOLS: Record<string, ToolManifest> = {
8080
};
8181

8282
let targetPlatform: string = process.platform;
83-
let validationBaseDir: string = __dirname;
83+
let validationBaseDir: string = path.join(__dirname, '..');
8484

8585
/**
8686
* Find the tool directory in the tools folder based on a pattern.
@@ -311,6 +311,16 @@ async function validateTool(name: string, manifest: ToolManifest): Promise<boole
311311
return allPassed;
312312
}
313313

314+
async function cleanupTempDir(dir: string | null) {
315+
if (dir) {
316+
try {
317+
await fs.rm(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
318+
} catch (err) {
319+
console.warn(`Warning: Could not clean up temp dir: ${err instanceof Error ? err.message : String(err)}`);
320+
}
321+
}
322+
}
323+
314324
async function main() {
315325
console.log('Tool Dependency Validation');
316326
console.log('═'.repeat(50));
@@ -334,6 +344,10 @@ async function main() {
334344

335345
// Create temp directory for extraction
336346
const tempDir = path.join(__dirname, '..', 'vsix-extracted-temp', 'extension');
347+
348+
// Pre-cleanup: remove tempDir if it exists
349+
await cleanupTempDir(tempDir);
350+
337351
await fs.mkdir(tempDir, { recursive: true });
338352

339353
// Extract VSIX (it's a ZIP file)
@@ -359,23 +373,14 @@ async function main() {
359373
}
360374

361375
console.log('\n' + '═'.repeat(50));
376+
362377
if (allToolsPassed) {
363378
console.log('✅ All tools validated successfully');
364-
365-
// Cleanup extracted VSIX if needed
366-
if (cleanupDir) {
367-
await fs.rm(cleanupDir, { recursive: true, force: true });
368-
}
369-
379+
await cleanupTempDir(cleanupDir);
370380
process.exit(0);
371381
} else {
372382
console.log('❌ Tool validation failed');
373-
374-
// Cleanup extracted VSIX if needed
375-
if (cleanupDir) {
376-
await fs.rm(cleanupDir, { recursive: true, force: true });
377-
}
378-
383+
await cleanupTempDir(cleanupDir);
379384
process.exit(1);
380385
}
381386
}

0 commit comments

Comments
 (0)