-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.js
30 lines (25 loc) · 922 Bytes
/
build.js
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
import * as cps from 'node:child_process';
const red = '\x1b[31m%s\x1b[0m';
const green = '\x1b[32m%s\x1b[0m';
const cyan = '\x1b[36m%s\x1b[0m';
const linkedProject = process.env.LINKED_PROJECT_PATH;
if (!linkedProject) {
console.error(red, 'LINKED_PROJECT not set');
process.exit(1);
}
const args = process.argv.slice(2);
if (args.length === 0) {
console.error(red, 'No arguments provided');
process.exit(1);
}
if (args.includes('--link')) {
cps.execSync(`pnpm link --dir ${linkedProject}`, { stdio: 'inherit' });
console.log(cyan, `ready to be linked from ${linkedProject}.`);
}
if (args.includes('--bundle')) {
cps.execSync(
`esbuild src/chessground.ts --bundle --format=esm --outfile=${linkedProject}/node_modules/chessground/dist/chessground.min.js`,
{ stdio: 'inherit' },
);
console.log(green, `compiled and built ${linkedProject}/node_modules/chessground/dist/chessground.min.js`);
}