feat(cli): Add —no-open option to cli dev command.

This commit is contained in:
Sam 2022-06-06 15:32:49 +02:00
parent 04ff15f89e
commit bc5b12fce3
No known key found for this signature in database
GPG Key ID: D004126FCD1A6DF0
3 changed files with 5 additions and 1 deletions

View File

@ -28,6 +28,7 @@ async function runDevServer({ context, directory }) {
LOWDEFY_BUILD_REF_RESOLVER: context.options.refResolver,
LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
LOWDEFY_PACKAGE_MANAGER: context.packageManager,
LOWDEFY_SERVER_DEV_OPEN_BROWSER: !!context.options.open,
LOWDEFY_SERVER_DEV_WATCH: JSON.stringify(context.options.watch),
LOWDEFY_SERVER_DEV_WATCH_IGNORE: JSON.stringify(context.options.watchIgnore),
PORT: context.options.port,

View File

@ -69,6 +69,7 @@ program
'Change config directory. Default is the current working directory.'
)
.option('--disable-telemetry', 'Disable telemetry.')
.option('--no-open', 'Do not open a new tab in the default browser.')
.option(
'--package-manager <package-manager>',
'The package manager to use. Options are "npm" or "yarn".'

View File

@ -80,7 +80,9 @@ async function run() {
try {
const serverPromise = startServer(context);
await wait(800);
opener(`http://localhost:${context.options.port}`);
if (process.env.LOWDEFY_SERVER_DEV_OPEN_BROWSER === 'true') {
opener(`http://localhost:${context.options.port}`);
}
await serverPromise;
} catch (error) {
console.log(error);