From 34d21f171fdacaf5ef9fc7ab89b5061188b5ff34 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Tue, 28 Jun 2022 10:58:55 -0400 Subject: [PATCH] wip: remove console waits for create-astro tests --- packages/create-astro/src/index.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/create-astro/src/index.ts b/packages/create-astro/src/index.ts index fba9b710cfe72..12a1a09a0320f 100644 --- a/packages/create-astro/src/index.ts +++ b/packages/create-astro/src/index.ts @@ -14,9 +14,12 @@ import { TEMPLATES } from './templates.js'; function wait(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } -function logAndWait(message: string, ms = 100) { - console.log(message); - return wait(ms); +function createLogAndWait({ isDryRun, defaultMs }: { isDryRun: boolean, defaultMs: number }) { + return function logAndWait(message: string, ms = defaultMs) { + console.log(message); + // avoid artificial delays in "dry run" / testing mode + return isDryRun ? null : wait(ms); + } } // NOTE: In the v7.x version of npm, the default behavior of `npm init` was changed // to no longer require `--` to pass args and instead pass `--` directly to us. This @@ -221,12 +224,13 @@ export async function main() { ora().succeed('Setup complete.'); ora({ text: green('Ready for liftoff!') }).succeed(); - await wait(300); - + !args.dryRun && await wait(300); + console.log(`\n${bgCyan(black(' Next steps '))}\n`); - + let projectDir = path.relative(process.cwd(), cwd); const devCmd = pkgManager === 'npm' ? 'npm run dev' : `${pkgManager} dev`; + const logAndWait = createLogAndWait({ isDryRun: args.dryRun, defaultMs: 100 }); await logAndWait( `You can now ${bold(cyan('cd'))} into the ${bold(cyan(projectDir))} project directory.`