mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 04:46:05 +00:00
init create cli, added node and partially cloudflare
This commit is contained in:
14
app/src/cli/utils/cli.ts
Normal file
14
app/src/cli/utils/cli.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export async function wait(ms: number) {
|
||||
return new Promise((r) => setTimeout(r, ms));
|
||||
}
|
||||
|
||||
export async function* typewriter(
|
||||
text: string,
|
||||
delay: number,
|
||||
transform?: (char: string) => string
|
||||
) {
|
||||
for (const char of text) {
|
||||
yield transform ? transform(char) : char;
|
||||
await wait(delay);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { execSync } from "node:child_process";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import url from "node:url";
|
||||
@@ -38,3 +39,15 @@ export async function fileExists(filePath: string) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function exec(command: string, opts?: { silent?: boolean; env?: Record<string, string> }) {
|
||||
const stdio = opts?.silent ? "pipe" : "inherit";
|
||||
const output = execSync(command, {
|
||||
stdio: ["inherit", stdio, stdio],
|
||||
env: { ...process.env, ...opts?.env }
|
||||
});
|
||||
if (!opts?.silent) {
|
||||
return;
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user