-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathbuild-binary.js
More file actions
38 lines (32 loc) · 1.08 KB
/
Copy pathbuild-binary.js
File metadata and controls
38 lines (32 loc) · 1.08 KB
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
36
37
38
import pkg from '@yao-pkg/pkg';
import packageJson from '../../package.json' with { type: 'json' };
import { getAssetPath } from './paths.js';
import { highlight } from './terminal.js';
const PLATFORMS = {
linux: 'linux',
macos: 'macos',
win: 'win',
};
const ARCHS = {
linux: 'x64',
macos: 'arm64',
win: 'x64',
};
/**
* Build a binary with @yao-pkg/pkg
* @param {string} version - The version to build
* @param {'linux'|'macos'|'win'} os - The operating system
* @returns {Promise<void>}
*/
export async function buildBinary(version, os) {
const input = getAssetPath('bundle', version, 'build');
const output = getAssetPath('binary', version, 'build', os);
const [nodeMajorVersion] = packageJson.volta.node.split('.');
const platform = PLATFORMS[os];
const arch = ARCHS[os];
const target = `node${nodeMajorVersion}-${platform}-${arch}`;
console.log(
highlight`=> Build script ${input} into binary ${output} for ${platform}-${arch} with Node.js ${nodeMajorVersion}`,
);
await pkg.exec([input, '--target', target, '--output', output, '--options', 'use-system-ca']);
}