Skip to content

Commit

Permalink
Remove intermediate files
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Nov 29, 2024
1 parent 7e77e17 commit 5ad96e4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const { values: options, positionals } = parseArgs({
verbose: { short: 'w', type: 'boolean', default: false },
output: { short: 'o', type: 'string' },
clean: { type: 'boolean', default: false },
keep: { type: 'boolean', default: false },
node: { short: 'N', type: 'string', default: 'v' + process.versions.node },
target: { short: 't', type: 'string', multiple: true, default: [process.platform + '-' + process.arch] },
},
Expand All @@ -33,7 +34,8 @@ Options:
--quiet,-q Hide non-error output
--verbose,-w Show all output
--output,-o <prefix> The output prefix
--clean Remove temporary files
--clean Remove cached files
--keep Keep intermediate files
--node,-N <version> Specify the Node version
--target,-t <target> Specify which targets(s) to build for (e.g. linux-arm64, win-x64)
`);
Expand Down Expand Up @@ -125,7 +127,17 @@ async function getNode(archiveBase: string) {
gzip: true,
cwd: join(tempDir, 'node'),
});
fs.copyFileSync(join(tempDir, 'node', archiveBase, isWindows ? 'node.exe' : 'bin/node'), execName);
const extracted = join(tempDir, 'node', archiveBase);
fs.copyFileSync(join(extracted, isWindows ? 'node.exe' : 'bin/node'), execName);
if (!options.keep) {
_log('Removing intermediate:', extracted);
fs.rmSync(extracted, { recursive: true, force: true });
}
}

if (!options.keep) {
_log('Removing intermediate:', archivePath);
fs.unlinkSync(archivePath);
}
}

Expand Down

0 comments on commit 5ad96e4

Please sign in to comment.