Skip to content

Commit

Permalink
Fix: astro add generating config outside project root (withastro#3186)
Browse files Browse the repository at this point in the history
* fix: astro.config generated outside project dir

* chore: changeset
  • Loading branch information
bholmesdev authored Apr 22, 2022
1 parent d789626 commit fa46e74
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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' });
}

Expand Down

0 comments on commit fa46e74

Please sign in to comment.