Nizzy sync utils.ts updated for windows (#1316)

This commit is contained in:
Fahad
2025-06-24 00:20:48 +05:30
committed by GitHub
parent 9fbc867a85
commit b39f4a2a4b

View File

@@ -16,10 +16,21 @@ export const getProjectRoot = async () => {
};
export const runCommand = async (command: string, args: string[], options: SpawnOptions = {}) => {
const child = spawn(command, args, { stdio: 'inherit', ...options });
await new Promise((resolve, reject) => {
child.once('close', resolve);
child.once('error', reject);
const useShell = process.platform === 'win32';
const finalCommand = command;
const finalArgs = args;
const spawnOptions: SpawnOptions = {
stdio: 'inherit',
...options,
...(useShell && options.shell === undefined ? { shell: true } : {})
};
const child = spawn(finalCommand, finalArgs, spawnOptions);
await new Promise<void>((resolve, reject) => {
child.once('close', () => resolve());
child.once('error', (err) => reject(err));
});
};