-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.js
24 lines (19 loc) · 835 Bytes
/
package.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
const { exec } = require('pkg');
const { name, version } = require('./package.json');
const fs = require('fs');
const packageDir = './packages';
const entry = './scripts/main.js';
const targets = ['node12-linux-x64', 'node12-macos-x64', 'node12-win-x64'];
const baseName = `${name}-${version}`.replace(/\./g, '-');
if (!fs.existsSync(packageDir)) {
fs.mkdirSync(packageDir);
}
const packageCode = async () => {
await exec([entry, '--target', targets[0], '--output', `${packageDir}/${baseName}-linux`]);
console.log(`Packaged for linux`);
await exec([entry, '--target', targets[1], '--output', `${packageDir}/${baseName}-macos`]);
console.log(`Packaged for mac`);
await exec([entry, '--target', targets[2], '--output', `${packageDir}/${baseName}-windows.exe`]);
console.log(`Packaged for windows`);
};
packageCode();