@bifravst/run
Advanced tools
Comparing version 1.1.1 to 1.2.0
/// <reference types="node" resolution-mode="require"/> | ||
declare const run: ({ command, args, input, log, cwd, }: { | ||
declare const run: ({ command, args, input, log, cwd, env, }: { | ||
command: string; | ||
@@ -7,2 +7,3 @@ args?: string[]; | ||
cwd?: string; | ||
env?: Record<string, string>; | ||
log?: { | ||
@@ -9,0 +10,0 @@ debug?: (...message: string[]) => void; |
import { spawn } from 'node:child_process'; | ||
import os from 'node:os'; | ||
const run = async ({ command, args, input, log, cwd, }) => new Promise((resolve, reject) => { | ||
const run = async ({ command, args, input, log, cwd, env, }) => new Promise((resolve, reject) => { | ||
log?.debug?.(`${command} ${args?.join(' ')}`); | ||
const p = spawn(command, args, { cwd }); | ||
const p = spawn(command, args, { cwd, env }); | ||
const result = []; | ||
@@ -7,0 +7,0 @@ const errors = []; |
@@ -68,2 +68,12 @@ import { describe, it, mock } from 'node:test'; | ||
}); | ||
void it('can be passed environment variables', async () => { | ||
const res = await run({ | ||
command: '/bin/bash', | ||
args: ['-c', 'echo $FOO'], | ||
env: { | ||
FOO: 'bar', | ||
}, | ||
}); | ||
assert.equal(res, `bar${os.EOL}`); | ||
}); | ||
}); |
{ | ||
"name": "@bifravst/run", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "run() wraps Node.js' spawn()", | ||
@@ -5,0 +5,0 @@ "exports": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8494
124