fix npm init flag handling in create-astro (#1862)

* fix npm init flag handling

* Update index.ts

* Update real-cats-act.md
This commit is contained in:
Fred K. Schott 2021-11-17 10:30:12 -08:00 committed by GitHub
parent 59eecad418
commit 6c66d4834b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'create-astro': patch
---
Fix issue with v7.x+ versions of npm init, which changed default flag handling

View file

@ -8,7 +8,13 @@ import yargs from 'yargs-parser';
import { FRAMEWORKS, COUNTER_COMPONENTS } from './frameworks.js';
import { TEMPLATES } from './templates.js';
import { createConfig } from './config.js';
const args = yargs(process.argv);
// 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
// broke our arg parser, since `--` is a special kind of flag. Filtering for `--` here
// fixes the issue so that create-astro now works on all npm version.
const cleanArgv = process.argv.filter(arg => arg !== '--')
const args = yargs(cleanArgv);
prompts.override(args);
export function mkdirp(dir: string) {