Skip to content

Commit df57ef8

Browse files
committed
Add new scripts from the sample
For windows!
1 parent d2db4c5 commit df57ef8

File tree

10 files changed

+98
-37
lines changed

10 files changed

+98
-37
lines changed

script/bootstrap

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@ var modulePath = path.join(".", "node_modules");
88
var rebuildPath = path.join(modulePath, ".bin", "electron-rebuild");
99
var prebuiltPath = path.join(modulePath, "electron-prebuilt");
1010
var prebuiltPackageJSONPath = path.join(prebuiltPath, "package.json");
11+
var npmCmd = "npm";
1112

1213
function jsonValue(path, value) { return JSON.parse(fs.readFileSync(path).toString())[value]; };
1314

14-
var electronVersion = jsonValue(prebuiltPackageJSONPath, "version");
15+
if (process.platform === 'win32') {
16+
npmCmd += '.cmd';
17+
rebuildPath += '.cmd';
18+
}
1519

16-
proc.spawnSync("npm", ["install"], {stdio: "inherit"});
17-
18-
var args = [
19-
"--version", electronVersion,
20-
"--electron-prebuilt-dir", prebuiltPath,
21-
"--module-dir", modulePath
22-
];
23-
24-
proc.spawn(rebuildPath, args, {stdio: "inherit"});
20+
var install = proc.spawn(npmCmd, ["install"], {stdio: "inherit"});
21+
install.on('close', function() {
22+
var electronVersion = jsonValue(prebuiltPackageJSONPath, "version");
23+
var args = [
24+
"--version", electronVersion,
25+
"--electron-prebuilt-dir", prebuiltPath,
26+
"--module-dir", modulePath
27+
];
28+
proc.spawn(rebuildPath, args, {stdio: "inherit"});
29+
});

script/bootstrap.cmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@IF EXIST "%~dp0\node.exe" (
2+
"%~dp0\node.exe" "%~dp0\bootstrap" %*
3+
) ELSE (
4+
node "%~dp0\bootstrap" %*
5+
)
6+

script/build

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var argv = require('yargs')
1111
function jsonValue(path, value) { return JSON.parse(fs.readFileSync(path).toString())[value]; };
1212

1313
var modulePath = path.join(".", "node_modules");
14-
var packagerCmd = path.join(modulePath, ".bin", "electron-packager");
14+
var packagerCmd = path.join(modulePath, "electron-packager", "cli.js");
1515
var prebuiltPath = path.join(modulePath, "electron-prebuilt");
1616
var prebuiltPackageJSONPath = path.join(prebuiltPath, "package.json");
1717
var buildOutputPath = path.join(".", "release");
@@ -22,30 +22,48 @@ var ignorePaths='node_modules/electron-compile/node_modules/electron-compilers|n
2222
var electronVersion = jsonValue(prebuiltPackageJSONPath, 'version');
2323
var appName = jsonValue('package.json', 'appName');
2424

25-
proc.spawnSync(compileCmd, [], {stdio: 'inherit'});
26-
27-
console.log('Building ', appName);
28-
29-
var args = [
30-
'./',
31-
appName,
32-
'--overwrite',
33-
'--platform', argv.platform,
34-
'--arch', argv.arch,
35-
'--version', electronVersion,
36-
'--ignore', ignorePaths,
37-
'--out', buildOutputPath
38-
];
39-
40-
var ignoreArgs = ['overwrite', 'platform', 'arch', 'version', 'ignore', 'out', '_', '$0']
41-
for(var arg in argv) {
42-
if (ignoreArgs.indexOf(arg) > -1) continue;
43-
44-
if (argv[arg] === true)
45-
args.push('--' + arg)
46-
else
47-
args.push('--' + arg, argv[arg])
25+
if (process.platform === 'win32') {
26+
compileCmd += '.cmd';
4827
}
4928

50-
args = args.concat(argv._);
51-
proc.spawn(packagerCmd, args, {stdio: 'inherit'});
29+
var iconPath;
30+
if (argv.platform === 'win32') {
31+
iconPath = path.join(".", "resources", "win", "app.ico")
32+
}
33+
else if (argv.platform === 'darwin') {
34+
iconPath = path.join(".", "resources", "mac", "app.icns")
35+
}
36+
else if (argv.platform === 'linux') {
37+
iconPath = path.join(".", "resources", "linux")
38+
}
39+
40+
var compile = proc.spawn(compileCmd, [], {stdio: 'inherit'});
41+
compile.on('close', function() {
42+
console.log('Building ', appName);
43+
44+
var args = [
45+
packagerCmd,
46+
'./',
47+
appName,
48+
'--overwrite',
49+
'--platform', argv.platform,
50+
'--arch', argv.arch,
51+
'--version', electronVersion,
52+
'--icon', iconPath,
53+
'--ignore', ignorePaths,
54+
'--out', buildOutputPath
55+
];
56+
57+
var ignoreArgs = ['overwrite', 'platform', 'arch', 'version', 'ignore', 'out', '_', '$0']
58+
for(var arg in argv) {
59+
if (ignoreArgs.indexOf(arg) > -1) continue;
60+
61+
if (argv[arg] === true)
62+
args.push('--' + arg)
63+
else
64+
args.push('--' + arg, argv[arg])
65+
}
66+
67+
args = args.concat(argv._);
68+
proc.spawn(process.execPath, args, {stdio: 'inherit'});
69+
});

script/build.cmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@IF EXIST "%~dp0\node.exe" (
2+
"%~dp0\node.exe" "%~dp0\build" %*
3+
) ELSE (
4+
node "%~dp0\build" %*
5+
)

script/compile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ var compilerPath = path.join(modulePath, ".bin", "electron-compile");
88
var pathsToCompile = [
99
path.join(".", "src"),
1010
path.join(".", "vendor")
11-
];
11+
]
1212
var compileCachepath = path.join(".", "compile-cache");
1313

1414
console.log("Compiling...");
1515

16+
if (process.platform === 'win32') {
17+
compilerPath += '.cmd';
18+
}
19+
1620
var args = [
1721
"--target", compileCachepath
1822
].concat(pathsToCompile);

script/compile.cmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@IF EXIST "%~dp0\node.exe" (
2+
"%~dp0\node.exe" "%~dp0\compile" %*
3+
) ELSE (
4+
node "%~dp0\compile" %*
5+
)

script/run

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ var argv = require('yargs')
99
var modulePath = path.join(".", "node_modules");
1010
var electronPath = path.join(modulePath, ".bin", "electron");
1111

12+
if (process.platform === 'win32') {
13+
electronPath += '.cmd';
14+
}
15+
1216
var args = [
1317
".",
1418
"--environment", argv.environment

script/run.cmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@IF EXIST "%~dp0\node.exe" (
2+
"%~dp0\node.exe" "%~dp0\run" %*
3+
) ELSE (
4+
node "%~dp0\run" %*
5+
)

script/test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ var args = [
88
"--test"
99
].concat(process.argv.slice(2));
1010

11+
if (process.platform === 'win32') {
12+
runPath += '.cmd';
13+
}
14+
1115
proc.spawn(runPath, args, {stdio: "inherit"});

script/test.cmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@IF EXIST "%~dp0\node.exe" (
2+
"%~dp0\node.exe" "%~dp0\test" %*
3+
) ELSE (
4+
node "%~dp0\test" %*
5+
)

0 commit comments

Comments
 (0)