fix(create-emdash): use async exec so spinner animates during install
This commit is contained in:
5
.changeset/fix-create-emdash-spinner.md
Normal file
5
.changeset/fix-create-emdash-spinner.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"create-emdash": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix spinner hanging during dependency installation by using async exec instead of execSync, which was blocking the event loop and preventing the spinner animation from updating.
|
||||||
@@ -6,9 +6,12 @@
|
|||||||
* Usage: npm create emdash@latest
|
* Usage: npm create emdash@latest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { execSync } from "node:child_process";
|
import { exec } from "node:child_process";
|
||||||
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
||||||
import { resolve } from "node:path";
|
import { resolve } from "node:path";
|
||||||
|
import { promisify } from "node:util";
|
||||||
|
|
||||||
|
const execAsync = promisify(exec);
|
||||||
|
|
||||||
import * as p from "@clack/prompts";
|
import * as p from "@clack/prompts";
|
||||||
import { downloadTemplate } from "giget";
|
import { downloadTemplate } from "giget";
|
||||||
@@ -251,10 +254,7 @@ async function main() {
|
|||||||
if (shouldInstall) {
|
if (shouldInstall) {
|
||||||
s.start(`Installing dependencies with ${pc.cyan(pm)}...`);
|
s.start(`Installing dependencies with ${pc.cyan(pm)}...`);
|
||||||
try {
|
try {
|
||||||
execSync(installCmd, {
|
await execAsync(installCmd, { cwd: projectDir });
|
||||||
cwd: projectDir,
|
|
||||||
stdio: "ignore",
|
|
||||||
});
|
|
||||||
s.stop("Dependencies installed!");
|
s.stop("Dependencies installed!");
|
||||||
} catch {
|
} catch {
|
||||||
s.stop("Failed to install dependencies");
|
s.stop("Failed to install dependencies");
|
||||||
|
|||||||
Reference in New Issue
Block a user