Skip to content

Commit

Permalink
fix(create-app): tmpdir handling (#5938)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmertens authored Mar 4, 2024
1 parent 1995753 commit b85761c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/create-qwik/src/run-create-interactive-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export async function runCreateInteractiveCli(): Promise<CreateAppResult> {

if (!runDepInstall) {
backgroundInstall.abort();
} else {
} else if (typeof backgroundInstall.success === 'undefined') {
try {
const joke = await confirm({
message: `Finishing the install. Wanna hear a joke?`,
Expand Down
14 changes: 9 additions & 5 deletions packages/qwik/src/cli/utils/install-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ export function backgroundInstallDeps(pkgManager: string, baseApp: IntegrationDa

const { install, abort } = installDeps(pkgManager, tmpInstallDir);

install.finally(() => {
fs.rmdirSync(tmpInstallDir, { recursive: true });
});

const complete = async (outDir: string) => {
let success = false;

Expand Down Expand Up @@ -63,6 +59,7 @@ export function backgroundInstallDeps(pkgManager: string, baseApp: IntegrationDa
}

success = true;
fs.rmdirSync(tmpInstallDir, { recursive: true });
}
} catch (e: any) {
if (e) {
Expand All @@ -86,7 +83,14 @@ export function backgroundInstallDeps(pkgManager: string, baseApp: IntegrationDa
return success;
};

return { abort, complete };
const out = {
abort: () => abort().finally(() => fs.rmdirSync(tmpInstallDir, { recursive: true })),
complete,
success: undefined as boolean | undefined,
};
install.then((success) => (out.success = success));

return out;
}

function setupTmpInstall(baseApp: IntegrationData) {
Expand Down

0 comments on commit b85761c

Please sign in to comment.