forked from creationix/topcube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopcube.js
41 lines (36 loc) · 1.18 KB
/
topcube.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
var spawn = require('child_process').spawn;
var path = require('path');
module.exports = function (options) {
options = options || {};
options.url = options.url || 'http://nodejs.org';
options.name = options.name || 'nodejs';
var client;
var keys = [];
switch (process.platform) {
case 'win32':
client = path.resolve(__dirname + '/cefclient/cefclient');
keys = ['url', 'name', 'width', 'height', 'minwidth', 'minheight', 'ico', 'cache-path', 'log-file'];
break;
case 'linux':
client = path.resolve(__dirname + (/0\.4\./.test(process.version) ? '/build/default/topcube' : '/build/Release/topcube'));
keys = ['url', 'name', 'width', 'height', 'minwidth', 'minheight'];
break;
default:
console.warn('');
return null;
break;
}
var args = [];
for (var key in options) {
if (keys.indexOf(key) !== -1) {
args.push('--' + key + '=' + options[key]);
}
}
var child = spawn(client, args);
child.on('exit', function(code) {
process.exit(code);
});
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
return child;
};