mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
cli create: fix installing deps spinner
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"bin": "./dist/cli/index.js",
|
||||
"version": "0.8.0-rc.1",
|
||||
"version": "0.8.0-rc.3",
|
||||
"description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, Remix, Astro, Cloudflare, Bun, Node, AWS Lambda & more.",
|
||||
"homepage": "https://bknd.io",
|
||||
"repository": {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { downloadTemplate } from "@bluwy/giget-core";
|
||||
import * as $p from "@clack/prompts";
|
||||
import type { CliCommand } from "cli/types";
|
||||
import { typewriter, wait } from "cli/utils/cli";
|
||||
import { exec, getVersion } from "cli/utils/sys";
|
||||
import { execAsync, getVersion } from "cli/utils/sys";
|
||||
import { Option } from "commander";
|
||||
import color from "picocolors";
|
||||
import { overridePackageJson, updateBkndPackages } from "./npm";
|
||||
@@ -190,7 +190,7 @@ async function action(options: { template?: string; dir?: string; integration?:
|
||||
|
||||
//console.log("url", url);
|
||||
const s = $p.spinner();
|
||||
s.start("Downloading template...");
|
||||
await s.start("Downloading template...");
|
||||
try {
|
||||
await downloadTemplate(url, {
|
||||
dir: ctx.dir,
|
||||
@@ -236,9 +236,9 @@ async function action(options: { template?: string; dir?: string; integration?:
|
||||
const install_cmd = template.scripts?.install || "npm install";
|
||||
|
||||
const s = $p.spinner();
|
||||
s.start("Installing dependencies...");
|
||||
await s.start("Installing dependencies...");
|
||||
try {
|
||||
exec(`cd ${ctx.dir} && ${install_cmd}`, { silent: true });
|
||||
await execAsync(`cd ${ctx.dir} && ${install_cmd}`, { silent: true });
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
s.stop("Failed to install: " + color.red(e.message), 1);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { execSync } from "node:child_process";
|
||||
import { execSync, exec as nodeExec } from "node:child_process";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import url from "node:url";
|
||||
@@ -51,3 +51,23 @@ export function exec(command: string, opts?: { silent?: boolean; env?: Record<st
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
export function execAsync(
|
||||
command: string,
|
||||
opts?: { silent?: boolean; env?: Record<string, string> }
|
||||
) {
|
||||
return new Promise((resolve, reject) => {
|
||||
nodeExec(
|
||||
command,
|
||||
{
|
||||
env: { ...process.env, ...opts?.env }
|
||||
},
|
||||
(err, stdout, stderr) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve(stdout);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user