diff options
author | 2021-07-30 18:44:24 +0200 | |
---|---|---|
committer | 2021-07-30 12:44:24 -0400 | |
commit | cf4c97cf5411bffbdc8522717e950b414053f26c (patch) | |
tree | 10ae0aca71cce39589fb4c3433e660fbfdf7a1ef /packages/create-astro/src | |
parent | 001594faa07867c0684b4c291c14cb1550956bdb (diff) | |
download | astro-cf4c97cf5411bffbdc8522717e950b414053f26c.tar.gz astro-cf4c97cf5411bffbdc8522717e950b414053f26c.tar.zst astro-cf4c97cf5411bffbdc8522717e950b414053f26c.zip |
forced degit template extraction in case of non empty installation directory (#937)
* revert recursive file removal routine
* forced degit overwrite without previous file removal
* add changeset
Diffstat (limited to 'packages/create-astro/src')
-rw-r--r-- | packages/create-astro/src/index.ts | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/packages/create-astro/src/index.ts b/packages/create-astro/src/index.ts index 1b337a368..1427327ce 100644 --- a/packages/create-astro/src/index.ts +++ b/packages/create-astro/src/index.ts @@ -20,26 +20,6 @@ export function mkdirp(dir: string) { } } -/** - * Delete all files, subdirectories, and symlinks in a given - * directory. - * - * @param dir the directory to empty - * @returns a promise for emptying a given directory - */ -export async function emptyDir(dir: string) { - const items = await fs.promises.readdir(dir); - return Promise.all( - items.map(async (item) => { - const itemPath = path.join(dir, item); - const stat = await fs.promises.stat(itemPath); - return stat.isDirectory() - ? fs.promises.rm(itemPath, { recursive: true, force: true }) // To remove directories - : fs.promises.unlink(itemPath); // Remove files and symlinks - }) - ); -} - const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8')); const POSTPROCESS_FILES = ['package.json', 'astro.config.mjs', 'CHANGELOG.md']; // some files need processing after copying. @@ -57,14 +37,13 @@ export async function main() { const response = await prompts({ type: 'confirm', name: 'forceOverwrite', - message: `Directory not empty. Delete ${cwd} to continue?`, + message: 'Directory not empty. Continue [force overwrite]?', initial: false, }); if (!response.forceOverwrite) { process.exit(1); } - - await emptyDir(cwd); + mkdirp(cwd); } } else { mkdirp(cwd); |