From 0cbeee69dc35ff306abd62bcca7f39944ffc31d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mu=CC=88ller?= Date: Wed, 9 Feb 2022 16:11:43 +0100 Subject: [PATCH 1/4] fix(cli): add missing default values --- packages/vitest/src/constants.ts | 1 + packages/vitest/src/node/cli.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/vitest/src/constants.ts b/packages/vitest/src/constants.ts index 913a436ac0b4..0fffb9ca639f 100644 --- a/packages/vitest/src/constants.ts +++ b/packages/vitest/src/constants.ts @@ -49,6 +49,7 @@ export const configDefaults: UserConfig = Object.freeze({ isolate: true, watchIgnore: [/\/node_modules\//, /\/dist\//], update: false, + run: !!process.env.CI, watch: !process.env.CI, reporters: ['default'], silent: false, diff --git a/packages/vitest/src/node/cli.ts b/packages/vitest/src/node/cli.ts index f8522e0c41af..d6538449f22c 100644 --- a/packages/vitest/src/node/cli.ts +++ b/packages/vitest/src/node/cli.ts @@ -35,6 +35,7 @@ cli cli .command('run [...filters]') + .option('--run', 'do not watch', { default: true }) .action(run) cli From 263ea7c6b5785ffc990599ca4bbfcb45820993ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mu=CC=88ller?= Date: Wed, 9 Feb 2022 16:17:42 +0100 Subject: [PATCH 2/4] fix(cli): properly start run mode --- packages/vitest/src/node/cli.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/vitest/src/node/cli.ts b/packages/vitest/src/node/cli.ts index d6538449f22c..da2da4b803ee 100644 --- a/packages/vitest/src/node/cli.ts +++ b/packages/vitest/src/node/cli.ts @@ -35,8 +35,7 @@ cli cli .command('run [...filters]') - .option('--run', 'do not watch', { default: true }) - .action(run) + .action(runInRunMode) cli .command('related [...filters]') @@ -44,26 +43,26 @@ cli cli .command('watch [...filters]') - .action(dev) + .action(run) cli .command('dev [...filters]') - .action(dev) + .action(run) cli .command('[...filters]') - .action(dev) + .action(run) cli.parse() +async function runInRunMode(cliFilters: string[], argv: UserConfig) { + await run(cliFilters, { ...argv, run: true }) +} + async function runRelated(relatedFiles: string[] | string, argv: UserConfig) { argv.related = relatedFiles argv.passWithNoTests ??= true - await dev([], argv) -} - -async function dev(cliFilters: string[], argv: UserConfig) { - await run(cliFilters, argv) + await run([], argv) } async function run(cliFilters: string[], options: UserConfig) { From ebd6046bd26953cc0d3abcc5983af8940418680f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mu=CC=88ller?= Date: Wed, 9 Feb 2022 21:06:02 +0100 Subject: [PATCH 3/4] fix(cli): do not enable `watch` if it wasn't enabled before --- packages/vitest/src/node/cli.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/vitest/src/node/cli.ts b/packages/vitest/src/node/cli.ts index da2da4b803ee..e9b7de56708c 100644 --- a/packages/vitest/src/node/cli.ts +++ b/packages/vitest/src/node/cli.ts @@ -35,7 +35,7 @@ cli cli .command('run [...filters]') - .action(runInRunMode) + .action((cliFilters: string[], argv: UserConfig) => run(cliFilters, { ...argv, run: true, watch: false })) cli .command('related [...filters]') @@ -55,10 +55,6 @@ cli cli.parse() -async function runInRunMode(cliFilters: string[], argv: UserConfig) { - await run(cliFilters, { ...argv, run: true }) -} - async function runRelated(relatedFiles: string[] | string, argv: UserConfig) { argv.related = relatedFiles argv.passWithNoTests ??= true From 8544bf517f0b6605c43d35527a7d0239c34285ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mu=CC=88ller?= Date: Wed, 9 Feb 2022 21:12:35 +0100 Subject: [PATCH 4/4] chore: cleanup rebase --- packages/vitest/src/node/plugins/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vitest/src/node/plugins/index.ts b/packages/vitest/src/node/plugins/index.ts index b5f1f0b24dc9..d89f8d2cf8a0 100644 --- a/packages/vitest/src/node/plugins/index.ts +++ b/packages/vitest/src/node/plugins/index.ts @@ -57,7 +57,7 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest()) options, ) options.api = resolveApiConfig(options) - options.watch = options.watch && !options.run + options.watch &&= !options.run process.env.BASE_URL ??= viteConfig.base process.env.MODE ??= viteConfig.mode