mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 20:39:05 +00:00
Fixes #10170
This commit is contained in:
@@ -456,14 +456,11 @@ function exec(command, options, callback) {
|
||||
return execFile(opts.file, opts.options, opts.callback);
|
||||
}
|
||||
|
||||
const kCustomPromisifySymbol = Symbol.for("nodejs.util.promisify.custom");
|
||||
|
||||
const customPromiseExecFunction = orig => {
|
||||
return (...args) => {
|
||||
let resolve;
|
||||
let reject;
|
||||
const promise = new Promise((res, rej) => {
|
||||
resolve = res;
|
||||
reject = rej;
|
||||
});
|
||||
const { resolve, reject, promise } = Promise.withResolvers();
|
||||
|
||||
promise.child = orig(...args, (err, stdout, stderr) => {
|
||||
if (err !== null) {
|
||||
@@ -479,12 +476,22 @@ const customPromiseExecFunction = orig => {
|
||||
};
|
||||
};
|
||||
|
||||
Object.defineProperty(exec, Symbol.for("nodejs.util.promisify.custom"), {
|
||||
Object.defineProperty(exec, kCustomPromisifySymbol, {
|
||||
__proto__: null,
|
||||
configurable: true,
|
||||
value: customPromiseExecFunction(exec),
|
||||
});
|
||||
|
||||
exec[kCustomPromisifySymbol][kCustomPromisifySymbol] = exec[kCustomPromisifySymbol];
|
||||
|
||||
Object.defineProperty(execFile, kCustomPromisifySymbol, {
|
||||
__proto__: null,
|
||||
configurable: true,
|
||||
value: customPromiseExecFunction(execFile),
|
||||
});
|
||||
|
||||
execFile[kCustomPromisifySymbol][kCustomPromisifySymbol] = execFile[kCustomPromisifySymbol];
|
||||
|
||||
/**
|
||||
* Spawns a new process synchronously using the given `file`.
|
||||
* @param {string} file
|
||||
|
||||
11
test/regression/issue/10170.test.ts
Normal file
11
test/regression/issue/10170.test.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { test, expect } from "bun:test";
|
||||
import { bunExe } from "harness";
|
||||
import { execFile } from "node:child_process";
|
||||
import util from "node:util";
|
||||
|
||||
test("issue 10170", async () => {
|
||||
const execFileAsync = util.promisify(execFile);
|
||||
const result = await execFileAsync(bunExe(), ["--version"]);
|
||||
expect(result.stdout).toContain(Bun.version);
|
||||
expect(result.stderr).toBe("");
|
||||
});
|
||||
Reference in New Issue
Block a user