@lbu/stdlib
Advanced tools
Comparing version 0.0.61 to 0.0.62
@@ -185,3 +185,3 @@ import { Logger } from "@lbu/insight"; | ||
* exec("uname -m"); | ||
* // => Promise<{ stdout: "x86_64\n", stderr: "" }> | ||
* // => Promise<{ stdout: "x86_64\n", stderr: "", exitCode: 0 }> | ||
* ``` | ||
@@ -191,3 +191,3 @@ */ | ||
command: string, | ||
): Promise<{ stdout: string; stderr: string }>; | ||
): Promise<{ stdout: string; stderr: string; exitCode: number }>; | ||
@@ -199,3 +199,3 @@ /** | ||
* spawn("ls", ["-al"], { cwd: "/home" }); | ||
* // => Promise<{ code: 0 }> | ||
* // => Promise<{ exitCode: 0 }> | ||
* ``` | ||
@@ -207,3 +207,3 @@ */ | ||
opts?: SpawnOptions, | ||
): Promise<{ code?: number }>; | ||
): Promise<{ exitCode: number }>; | ||
@@ -210,0 +210,0 @@ /** |
{ | ||
"name": "@lbu/stdlib", | ||
"version": "0.0.61", | ||
"version": "0.0.62", | ||
"description": "All kinds of utility functions", | ||
@@ -17,3 +17,3 @@ "main": "./index.js", | ||
"dependencies": { | ||
"@lbu/insight": "0.0.61", | ||
"@lbu/insight": "0.0.62", | ||
"@types/node": "14.6.0", | ||
@@ -44,3 +44,3 @@ "dotenv": "8.2.0", | ||
}, | ||
"gitHead": "34d01d169e93516b1b7dd91c97c90d1c5d66cb67" | ||
"gitHead": "1cf32f25700229a1c20488776304a4c05884d88e" | ||
} |
@@ -14,6 +14,13 @@ import { exec as cpExec, spawn as cpSpawn } from "child_process"; | ||
* @param {string} command | ||
* @returns {Promise<object<{stdout: string, stderr: string}>>} | ||
* @returns {Promise<{stdout: string, stderr: string, exitCode: number}>} | ||
*/ | ||
export function exec(command) { | ||
return internalExec(command, { encoding: "utf8" }); | ||
export async function exec(command) { | ||
const promise = internalExec(command, { encoding: "utf8" }); | ||
const { stdout, stderr } = await promise; | ||
return { | ||
stdout, | ||
stderr, | ||
exitCode: promise.child.exitCode ?? 0, | ||
}; | ||
} | ||
@@ -25,3 +32,3 @@ | ||
* @param {object} [opts={}] | ||
* @returns {Promise<{code: number|undefined}>} | ||
* @returns {Promise<{exitCode: number}>} | ||
*/ | ||
@@ -34,3 +41,3 @@ export function spawn(command, args, opts = {}) { | ||
sp.once("exit", (code) => { | ||
resolve({ code: code === null ? undefined : code }); | ||
resolve({ exitCode: code ?? 0 }); | ||
}); | ||
@@ -37,0 +44,0 @@ }); |
37261
1197
+ Added@lbu/insight@0.0.62(transitive)
- Removed@lbu/insight@0.0.61(transitive)
Updated@lbu/insight@0.0.62