-
-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathwebext.run.js
29 lines (25 loc) · 967 Bytes
/
webext.run.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
import webExt from 'web-ext'
import fs from 'node:fs'
import path from 'node:path'
import { ADDON_PATH } from './utils.js'
let lastArg = process.argv[process.argv.length - 1]
if (!lastArg || lastArg.startsWith('-')) lastArg = 'firefox'
const IS_FF = lastArg.includes('irefox') || lastArg.includes('loorp') || lastArg.includes('zen')
const cliOpts = {
target: IS_FF ? 'firefox-desktop' : 'chromium',
sourceDir: ADDON_PATH,
keepProfileChanges: true,
}
async function main() {
if (IS_FF) {
cliOpts.firefox = lastArg
cliOpts.firefoxProfile = './build/profile-' + path.basename(lastArg).split(".")[0]
await fs.promises.mkdir(cliOpts.firefoxProfile, { recursive: true })
} else {
cliOpts.chromiumBinary = lastArg
cliOpts.chromiumProfile = './build/profile-' + path.basename(lastArg).split(".")[0]
await fs.promises.mkdir(cliOpts.chromiumProfile, { recursive: true })
}
webExt.cmd.run(cliOpts, { shouldExitProgram: true })
}
main()