-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mjs
35 lines (28 loc) · 880 Bytes
/
build.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers';
import { execSync } from 'child_process';
import * as fs from 'fs';
const addition = `
export type TagVec = string[];
`;
const argv = yargs(hideBin(process.argv)).argv;
async function build(args) {
const flags = ['--platform', '--dts', 'index.d.ts', '--js', 'index.js'];
if (args.release) {
flags.push('--release');
}
if (args.target) {
flags.push('--target');
flags.push(args.target);
}
const command = `npx napi build ${flags.join(' ')}`;
try {
execSync(command, { stdio: 'inherit' });
await fs.promises.appendFile('index.d.ts', addition, { encoding: 'utf-8' });
console.log("build.mjs: Modified generated typings");
} catch (error) {
console.error('Build failed:', error);
process.exit(1);
}
}
build(argv);