summaryrefslogtreecommitdiff
path: root/packages/create-astro/src/utils.ts
diff options
context:
space:
mode:
authorGravatar 木杉 <zhmushan@qq.com> 2021-05-26 06:16:49 +0800
committerGravatar GitHub <noreply@github.com> 2021-05-25 17:16:49 -0500
commit760a7a5509fc81a63d47948dbe040dcc8007d0fe (patch)
treea30287a5daa3b97a3ca7a5a34ecd021994152fea /packages/create-astro/src/utils.ts
parentf5ecbee192ef24f52f78ffad0ba7bce686bd45c7 (diff)
downloadastro-760a7a5509fc81a63d47948dbe040dcc8007d0fe.tar.gz
astro-760a7a5509fc81a63d47948dbe040dcc8007d0fe.tar.zst
astro-760a7a5509fc81a63d47948dbe040dcc8007d0fe.zip
Support skip install deps (#242)
* Support skip install deps * fmt * Create new-hats-deliver.md Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Diffstat (limited to 'packages/create-astro/src/utils.ts')
-rw-r--r--packages/create-astro/src/utils.ts14
1 files changed, 6 insertions, 8 deletions
diff --git a/packages/create-astro/src/utils.ts b/packages/create-astro/src/utils.ts
index 52e56f5f0..892e01076 100644
--- a/packages/create-astro/src/utils.ts
+++ b/packages/create-astro/src/utils.ts
@@ -61,16 +61,14 @@ export async function rewriteFiles(projectName: string) {
return Promise.all(tasks);
}
-export async function prepareTemplate(use: 'npm' | 'yarn', name: string, dest: string) {
- const projectName = dest;
- dest = resolve(dest);
- const template = fileURLToPath(new URL(`./templates/${name}.tgz`, import.meta.url));
+export async function prepareTemplate(options: { use: 'npm' | 'yarn'; templateName: string; projectName: string; skipInstall?: boolean }) {
+ const { use, templateName, projectName, skipInstall } = options;
+ const dest = resolve(projectName);
+ const template = fileURLToPath(new URL(`./templates/${templateName}.tgz`, import.meta.url));
await decompress(template, dest);
await rewriteFiles(projectName);
- try {
- await run(use, use === 'npm' ? 'i' : null, dest);
- } catch (e) {
- cleanup(true);
+ if (!skipInstall) {
+ await run(use, use === 'npm' ? 'i' : null, dest).catch(() => cleanup(true));
}
isDone = true;
return;