Skip to content

Commit

Permalink
feat: add --yes flag to simplify astro add
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Apr 27, 2022
1 parent 2d26b58 commit 460e28e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/create-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ export async function main() {
}

const astroAddCommand = installResponse.install
? 'astro add'
: `${pkgManagerExecCommand(pkgManager)} astro@latest add`;
? 'astro add --yes'
: `${pkgManagerExecCommand(pkgManager)} astro@latest add --yes`;

const astroAddResponse = await prompts({
type: 'confirm',
Expand All @@ -221,7 +221,7 @@ export async function main() {
if (astroAddResponse.astroAdd && !args.dryrun) {
await execaCommand(
astroAddCommand,
astroAddCommand === 'astro add'
astroAddCommand === 'astro add --yes'
? { cwd, stdio: 'inherit', localDir: cwd, preferLocal: true }
: { cwd, stdio: 'inherit' }
);
Expand Down
4 changes: 2 additions & 2 deletions packages/create-astro/test/astro-add-step.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('[create-astro] astro add', function () {
seen.add(installPrompt);
stdin.write('\x0D');
}
if (chunk.includes(PROMPT_MESSAGES.astroAdd('astro add'))) {
if (chunk.includes(PROMPT_MESSAGES.astroAdd('astro add --yes'))) {
resolve();
}
});
Expand All @@ -57,7 +57,7 @@ describe('[create-astro] astro add', function () {
seen.add(installPrompt);
stdin.write('n\x0D');
}
if (chunk.includes(PROMPT_MESSAGES.astroAdd('npx astro@latest add'))) {
if (chunk.includes(PROMPT_MESSAGES.astroAdd('npx astro@latest add --yes'))) {
resolve();
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/create-astro/test/install-step.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('[create-astro] install', function () {
return promiseWithTimeout((resolve) => {
const seen = new Set();
const installPrompt = PROMPT_MESSAGES.install(FAKE_PACKAGE_MANAGER);
const astroAddPrompt = PROMPT_MESSAGES.astroAdd('npx astro@latest add');
const astroAddPrompt = PROMPT_MESSAGES.astroAdd();
stdout.on('data', (chunk) => {
if (!seen.has(PROMPT_MESSAGES.template) && chunk.includes(PROMPT_MESSAGES.template)) {
seen.add(PROMPT_MESSAGES.template);
Expand Down
2 changes: 1 addition & 1 deletion packages/create-astro/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const PROMPT_MESSAGES = {
directory: 'Where would you like to create your app?',
template: 'Which app template would you like to use?',
install: (pkgManager) => `Would you like us to run "${pkgManager} install?"`,
astroAdd: (astroAddCommand) => `Run "${astroAddCommand}?" This lets you optionally add component frameworks (ex. React), CSS frameworks (ex. Tailwind), and more.`,
astroAdd: (astroAddCommand = 'npx astro@latest add --yes') => `Run "${astroAddCommand}?" This lets you optionally add component frameworks (ex. React), CSS frameworks (ex. Tailwind), and more.`,
};

export function setup(args = []) {
Expand Down

0 comments on commit 460e28e

Please sign in to comment.