Skip to content

Commit bd7c23e

Browse files
authored
Merge pull request #2734 from kravetsone/replace-zx-with-child-process
Replace `zx` with native `child_process`
2 parents 8e428d1 + f9ee2aa commit bd7c23e

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

drizzle-kit/src/utils/certs.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
import envPaths from 'env-paths';
22
import { mkdirSync } from 'fs';
33
import { access, readFile } from 'fs/promises';
4+
import { exec, ExecOptions } from 'node:child_process';
45
import { join } from 'path';
5-
import { $ } from 'zx';
66

7-
export const certs = async () => {
8-
$.verbose = false;
7+
export function runCommand(command: string, options: ExecOptions = {}) {
8+
return new Promise<{ exitCode: number }>((resolve) => {
9+
exec(command, options, (error) => {
10+
return resolve({ exitCode: error?.code ?? 0 });
11+
});
12+
});
13+
}
914

10-
const res = await $`mkcert --help`.nothrow();
15+
export const certs = async () => {
16+
const res = await runCommand('mkcert --help');
1117

1218
if (res.exitCode === 0) {
1319
const p = envPaths('drizzle-studio', {
1420
suffix: '',
1521
});
1622

17-
$.cwd = p.data;
18-
1923
// create ~/.local/share/drizzle-studio
2024
mkdirSync(p.data, { recursive: true });
2125

26+
// ~/.local/share/drizzle-studio
2227
const keyPath = join(p.data, 'localhost-key.pem');
2328
const certPath = join(p.data, 'localhost.pem');
2429

@@ -27,7 +32,7 @@ export const certs = async () => {
2732
await Promise.all([access(keyPath), access(certPath)]);
2833
} catch (e) {
2934
// if not create them
30-
await $`mkcert localhost`.nothrow();
35+
await runCommand(`mkcert localhost`, { cwd: p.data });
3136
}
3237
const [key, cert] = await Promise.all([
3338
readFile(keyPath, { encoding: 'utf-8' }),

0 commit comments

Comments
 (0)