-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
51 lines (41 loc) · 1.08 KB
/
test.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
#!/usr/bin/env node
'use strict';
const {exec} = require('node:child_process');
const yargs = require('yargs/yargs');
const argv = yargs(process.argv.slice(2)).options({
s: {alias: 'source-dir', nargs: 1, type: 'string'},
p: {alias: 'profile', nargs: 1, type: 'string'},
}).check(({sourceDir, profile}) => {
if (Array.isArray(sourceDir)) {
return "Too many argument for 'source-dir'.";
}
if (Array.isArray(profile)) {
return "Too many argument for 'profile'.";
}
return true;
}).argv;
const options = [
'--start-url about:addons',
'--start-url about:debugging',
'--verbose',
'--browser-console',
];
const profile = argv.profile;
if (profile) {
options.push(`--firefox-profile=${profile} --profile-create-if-missing`);
}
const sourceDir = argv.sourceDir;
if (sourceDir) {
options.push(`--source-dir=${sourceDir}`);
}
const main = () => {
const cmd = `web-ext run ${options.join(' ')}`;
console.log(`# Running command:\n ${cmd}`);
exec(cmd, (error, _stdout, _stderr) => {
if (error) {
console.error("\n", error);
return;
}
});
};
main();