Fix: astro add generating config outside project root (#3186)

* fix: astro.config generated outside project dir

* chore: changeset
This commit is contained in:
Ben Holmes 2022-04-22 15:17:16 -04:00 committed by GitHub
parent 75dab3ca3d
commit 2b702d6aba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix: astro add generating "astro.config.mjs" outside project root

View file

@ -19,6 +19,7 @@ import { parseNpmName } from '../util.js';
import { wrapDefaultExport } from './wrapper.js';
import { ensureImport } from './imports.js';
import { t, parse, visit, generate } from './babel.js';
import { appendForwardSlash } from '../path.js';
export interface AddOptions {
logging: LogOptions;
@ -91,7 +92,7 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO
debug('add', `Found config at ${configURL}`);
} else {
info(logging, 'add', `Unable to locate a config file, generating one for you.`);
configURL = new URL('./astro.config.mjs', root);
configURL = new URL('./astro.config.mjs', appendForwardSlash(root.href));
await fs.writeFile(fileURLToPath(configURL), CONSTS.CONFIG_STUB, { encoding: 'utf-8' });
}