-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.js
59 lines (49 loc) · 1.27 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const NWJS_VERSION = process.argv[2];
console.log("build for", NWJS_VERSION);
const cp = require('child_process');
const path = require('path');
const os = require('os');
const NwBuilder = require('nw-builder');
const IS_WINDOWS = os.platform() == 'win32';
const nwBuild = function () {
console.log('build nwjs');
var nw = new NwBuilder({
version: NWJS_VERSION,
files: [
'index.html',
'package.json',
'node_modules/bindings/*',
'build/Release/*.node',
],
platforms: IS_WINDOWS ? ['win32', 'win64'] : ['osx64'],
buildDir: '.',
appName: "MyApp", // auto detect from package.json
appVersion: "0.0.1",
zip: false,
});
nw.on('log', console.log);
nw.build().then(() => {
console.log('package created');
}).catch((err) => {
console.log('Build failed !!!', err);
});
};
if (IS_WINDOWS) {
const lib = path.join(__dirname, '');
cp.spawn(path.join(__dirname, 'rename_import_lib/rename_import_lib.exe'), [
'-i', 'build/Release/nw_simple_addon.node',
'-o', 'build/Release/nw_simple_addon.node',
'-s', 'NW_RENAMED',
'-r', 'nw.exe', 'MyApp.exe',
], {
cwd: __dirname,
stdio: [0, 1, 2],
}).on('close', function (ret) {
if (ret !== 0) {
throw new Error('rename_import_lib failed: ' + ret);
}
nwBuild();
});
} else {
nwBuild();
}