| 1 | #!/usr/bin/env node |
| 2 | |
| 3 | 'use strict'; |
| 4 | |
| 5 | const open = require('open'); |
| 6 | const os = require('os'); |
| 7 | const osName = require('os-name'); |
| 8 | const {resolve} = require('path'); |
| 9 | const {argv} = require('yargs'); |
| 10 | |
| 11 | const EXTENSION_PATH = resolve('./edge/build/unpacked'); |
| 12 | const START_URL = argv.url || 'https://react.dev/'; |
| 13 | |
| 14 | const extargs = `--load-extension=${EXTENSION_PATH}`; |
| 15 | |
| 16 | const osname = osName(os.platform()); |
| 17 | let appname; |
| 18 | |
| 19 | if (osname && osname.toLocaleLowerCase().startsWith('windows')) { |
| 20 | appname = 'msedge'; |
| 21 | } else if (osname && osname.toLocaleLowerCase().startsWith('mac')) { |
| 22 | appname = 'Microsoft Edge'; |
| 23 | } else if (osname && osname.toLocaleLowerCase().startsWith('linux')) { |
| 24 | //Coming soon |
| 25 | } |
| 26 | |
| 27 | if (appname) { |
| 28 | (async () => { |
| 29 | await open(START_URL, {app: [appname, extargs]}); |
| 30 | })(); |
| 31 | } |