|
| 1 | +import { Command, Option } from "commander"; |
| 2 | +import * as fs from "fs"; |
| 3 | +import * as path from "path"; |
| 4 | +import extensionConfig from "../webpack.config.mjs"; |
| 5 | + |
| 6 | +const targetMapping = { |
| 7 | + "win32-x64": "node-napi.win32-x64-msvc.node", |
| 8 | + "win32-arm64": "node-napi.win32-arm64-msvc.node", |
| 9 | + "linux-x64": "node-napi.linux-x64-gnu.node", |
| 10 | + "linux-arm64": "node-napi.linux-arm64-gnu.node", |
| 11 | + "linux-armhf": "node-napi.linux-arm-gnueabihf.node", |
| 12 | + "alpine-x64": "node-napi.linux-x64-musl.node", |
| 13 | + "darwin-x64": "node-napi.darwin-x64.node", |
| 14 | + "darwin-arm64": "node-napi.darwin-arm64.node", |
| 15 | + "alpine-arm64": "node-napi.linux-arm64-musl.node", |
| 16 | +}; |
| 17 | + |
| 18 | +const args = new Command() |
| 19 | + .addOption( |
| 20 | + new Option("--target [platform]", "Specify the target VS Code platform") |
| 21 | + .choices(Object.keys(targetMapping)) |
| 22 | + .makeOptionMandatory(), |
| 23 | + ) |
| 24 | + .parse() |
| 25 | + .opts(); |
| 26 | + |
| 27 | +const outDir = extensionConfig[0].output.path; |
| 28 | +for (const file of fs.readdirSync(outDir)) { |
| 29 | + if (file === targetMapping[args.target]) { |
| 30 | + continue; |
| 31 | + } else if (file.startsWith("node-napi")) { |
| 32 | + console.log(`Deleting file: ${file}`); |
| 33 | + fs.unlinkSync(path.join(outDir, file)); |
| 34 | + } |
| 35 | +} |
0 commit comments