From 385b00642db7fe6e81760c80e8c01e29c7688e20 Mon Sep 17 00:00:00 2001 From: rakannimer Date: Fri, 7 Feb 2020 15:44:02 +0200 Subject: [PATCH] feat(docz-core): pass down cli args to Gatsby + fix open flag --- .../src/bundler/machine/services/exec-dev-command.ts | 6 +++++- core/docz-core/src/config/argv.ts | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/docz-core/src/bundler/machine/services/exec-dev-command.ts b/core/docz-core/src/bundler/machine/services/exec-dev-command.ts index be50438da..ca474f073 100644 --- a/core/docz-core/src/bundler/machine/services/exec-dev-command.ts +++ b/core/docz-core/src/bundler/machine/services/exec-dev-command.ts @@ -35,9 +35,10 @@ export const execDevCommand = async ({ args }: ServerMachineCtx) => { // For monorepos that install dependencies higher in the fs tree const repoRootPath = get(args, 'repoRootPath', await findRootPath()) const gatsbyPath = path.join(repoRootPath, 'node_modules/.bin/gatsby') + const cliArgs = process.argv.slice(3) spawn( gatsbyPath, - ['develop', '--host', `${args.host}`, '--port', `${args.port}`], + ['develop', '--host', `${args.host}`, '--port', `${args.port}`, ...cliArgs], { stdio: 'inherit', cwd: paths.docz, @@ -52,5 +53,8 @@ export const execDevCommand = async ({ args }: ServerMachineCtx) => { }) console.log() console.log('App ready on ' + url) + if (args.open !== null && Boolean(args.open) === false) { + return + } openBrowser(url) } diff --git a/core/docz-core/src/config/argv.ts b/core/docz-core/src/config/argv.ts index 6ab1590db..d18a8280e 100644 --- a/core/docz-core/src/config/argv.ts +++ b/core/docz-core/src/config/argv.ts @@ -59,7 +59,7 @@ export interface Argv { port: number native: boolean notUseSpecifiers: boolean - openBrowser: boolean + open: null | boolean /* template args */ title: string description: string @@ -169,6 +169,6 @@ export const setArgs = (yargs: Yargs) => { alias: ['o', 'open'], describe: 'auto open browser in dev mode', type: 'boolean', - default: false, + default: null, }) }