Skip to content

Commit

Permalink
wip: remove console waits for create-astro tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Jun 28, 2022
1 parent eafd09e commit 34d21f1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/create-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.`
Expand Down

0 comments on commit 34d21f1

Please sign in to comment.