-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart_chrome.js
49 lines (40 loc) · 1.16 KB
/
start_chrome.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
const path = require('path');
const child_process = require('child_process');
const util = require('util');
const exec = util.promisify(child_process.exec);
const dir = path.resolve(__dirname, 'extension');
async function crossStartChrome() {
let cp;
const args = ['--profile-directory=FreshRSS', `--load-extension="${dir}"`, 'chrome://extensions/'];
switch (process.platform) {
case "darwin": // mac-osx
let {stdout} = await exec('mdfind kMDItemCFBundleIdentifier==com.google.Chrome');
stdout = stdout.trim();
if (stdout) throw new Error('Chrome not found');
cp = child_process.spawn(
`${stdout}/Contents/MacOS/Google Chrome`,
args
);
break;
case 'win32':
cp = child_process.spawn(
'start',
['chrome', ...args],
{shell: true}
);
break;
default:
cp = child_process.spawn(
'google-chrome',
args
);
}
cp.stderr.pipe(process.stderr);
cp.stdout.pipe(process.stdout);
cp.on('error', console.error);
cp.on('close', code => process.exit(code));
}
crossStartChrome().catch(e => {
console.error(e);
process.exit(1);
});