Fixed exec helper return
Some checks failed
Publish Library / Build NPM Project (push) Failing after 18s
Publish Library / Publish CDN & Docs (push) Has been skipped
Publish Library / Tag Version (push) Has been skipped

This commit is contained in:
2025-12-27 14:36:06 -05:00
parent e9ccd5ffb0
commit a5e940b003
2 changed files with 13 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ztimson/node-utils", "name": "@ztimson/node-utils",
"version": "1.0.4", "version": "1.0.5",
"description": "CSS Utility Classes", "description": "CSS Utility Classes",
"author": "ztimson", "author": "ztimson",
"license": "MIT", "license": "MIT",

View File

@@ -1,11 +1,18 @@
import {exec, execSync} from 'child_process'; import {execSync} from 'child_process';
import {spawn} from 'node:child_process';
export function $(str: TemplateStringsArray, ...args: string[]): Promise<string> { export function $(str: TemplateStringsArray, ...args: string[]): Promise<string> {
let cmd = str.reduce((acc, part, i) => acc + part + (args[i] || ''), ''); let cmd = str.reduce((acc, part, i) => acc + part + (args[i] || ''), '');
return new Promise((res, rej) => exec(cmd, (err, stdout, stderr) => { return new Promise((res, rej) => {
if(err) return rej(stderr || err); const proc = spawn(cmd, {shell: true});
return res(stdout); let stdout = '', stderr = '';
})) proc.stdout.on('data', (data) => stdout += data);
proc.stderr.on('data', (data) => stderr += data);
proc.on('close', (code) => {
if(code !== 0) return rej(new Error(stderr || stdout));
res(stdout.trim());
});
});
} }
export function $Sync(str: TemplateStringsArray, ...args: string[]): string { export function $Sync(str: TemplateStringsArray, ...args: string[]): string {