Skip to content

Commit

Permalink
Define the "open" flag for the dev command
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Oct 20, 2024
1 parent 67fd70c commit 1267aeb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion programs/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,20 @@ extensionJs
'-p, --port <number>',
'what port should Extension.js WebSocket server run. Defaults to `8000`'
)
.option(
'-o, --open [boolean]',
'whether or not to open the browser automatically. Defaults to `true`'
)
.action(async function (
pathOrRemoteUrl: string,
{browser = 'chrome', ...devOptions}: DevOptions
) {
for (const vendor of vendors(browser)) {
await extensionDev(pathOrRemoteUrl, {
browser: vendor as DevOptions['browser'],
...devOptions
...devOptions,
// @ts-expect-error open is a boolean
open: devOptions.open === 'false' ? false : true
})
}
})
Expand Down
2 changes: 1 addition & 1 deletion programs/develop/commands/commands-lib/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {BuildOptions} from '../build'

type BrowserConfig = Pick<
DevOptions,
| 'noOpen'
| 'open'
| 'profile'
| 'preferences'
| 'browserFlags'
Expand Down
2 changes: 1 addition & 1 deletion programs/develop/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface DevOptions {
browser: 'chrome' | 'edge' | 'firefox' | 'chromium-based' | 'gecko-based'
mode: 'development' | 'production' | 'none' | undefined
port?: number
noOpen?: boolean
open?: boolean
userDataDir?: string
profile?: string
preferences?: Record<string, any>
Expand Down
2 changes: 1 addition & 1 deletion programs/develop/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface StartOptions {
mode: 'development' | 'production'
browser: DevOptions['browser']
port?: number
noOpen?: boolean
open?: boolean
userDataDir?: string
polyfill?: boolean
chromiumBinary?: string
Expand Down
3 changes: 2 additions & 1 deletion programs/develop/webpack/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export default function webpackConfig(
stats: true,
port: devOptions.port || 8000
}),
!devOptions.noOpen &&
// Open defaults to true
devOptions.open !== false &&
new BrowsersPlugin({
extension: [
userExtensionOutputPath,
Expand Down

0 comments on commit 1267aeb

Please sign in to comment.