Skip to content

Commit

Permalink
feat(kkt): Command add openBrowser option.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 6, 2020
1 parent cb330bd commit 932b667
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/kkt-core/src/command/start/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export function builder(yarg: Argv) {
describe: 'port.',
type: 'number',
default: 19870
}
},
openBrowser: {
describe: 'Open Browser.',
type: 'boolean',
default: true
},
})
.example(`$ ${color.green('kkt')} start `, 'Runs the app in development mode.')
.example(`$ ${color.green('kkt')} start --emptyDir`, 'Build your project.');
Expand Down
5 changes: 4 additions & 1 deletion packages/kkt-core/src/command/start/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const isInteractive = process.stdout.isTTY;
export default async function (args: Argv & {
port: number;
host: string;
openBrowser: boolean;
}) {
// Tools like Cloud9 rely on this.
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || args.port || 19870;
Expand Down Expand Up @@ -109,7 +110,9 @@ export default async function (args: Argv & {
}

console.log(color.cyan('Starting the development server...\n'));
openBrowser(urls.localUrlForBrowser);
if(args.openBrowser) {
openBrowser(urls.localUrlForBrowser);
}
});

['SIGINT', 'SIGTERM'].forEach((sig) => {
Expand Down

0 comments on commit 932b667

Please sign in to comment.