Skip to content

Commit 989754c

Browse files
committed
fix(create-astro): error when --add and --no-install are used together
1 parent c6f2593 commit 989754c

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

.changeset/friendly-knives-rest.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-astro': patch
3+
---
4+
5+
Errors when `--add` and `--no-install` flags are used together, as `--add` requires dependencies to be installed

packages/create-astro/src/actions/context.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ export async function getContext(argv: string[]): Promise<Context> {
9191
'--ref': ref,
9292
'--add': add,
9393
} = flags;
94+
95+
if (add?.length && noInstall) {
96+
console.error(
97+
'The --add flag requires dependencies to be installed. Remove --no-install or run `astro add` manually after installation.',
98+
);
99+
process.exit(1);
100+
}
101+
94102
let projectName = cwd;
95103

96104
if (no) {

packages/create-astro/test/context.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,16 @@ describe('context', () => {
7171
const ctx = await getContext(['--no-git']);
7272
assert.deepEqual(ctx.git, false);
7373
});
74+
75+
it('--add with --no-install conflicts', async () => {
76+
const exitCode = await new Promise((resolve) => {
77+
const originalExit = process.exit;
78+
process.exit = (code) => {
79+
process.exit = originalExit;
80+
resolve(code);
81+
};
82+
getContext(['--add', 'cloudflare', '--no-install']);
83+
});
84+
assert.equal(exitCode, 1);
85+
});
7486
});

0 commit comments

Comments
 (0)