From aa606b23df47bc87f7eb3d4e730ea018f0de0ade Mon Sep 17 00:00:00 2001 From: jhmaster2000 <32803471+jhmaster2000@users.noreply.github.com> Date: Fri, 8 Dec 2023 15:46:29 -0300 Subject: [PATCH] polyfills: fix which options.cwd handling --- packages/bun-polyfills/src/global/process.ts | 2 +- packages/bun-polyfills/src/modules/bun.ts | 8 +++----- packages/bun-polyfills/tools/bun_test_loader.mjs | 2 +- packages/bun-polyfills/tools/test_all.js | 1 + 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/bun-polyfills/src/global/process.ts b/packages/bun-polyfills/src/global/process.ts index 0b7161eade..ce7f87b546 100644 --- a/packages/bun-polyfills/src/global/process.ts +++ b/packages/bun-polyfills/src/global/process.ts @@ -16,7 +16,7 @@ if (typeof process === 'object' && process !== null) { process.versions.c_ares = '0e7a5dee0fbb04080750cf6eabbe89d8bae87faa' satisfies Process['versions'][string]; process.versions.zig = '0.12.0-dev.1604+caae40c21' satisfies Process['versions'][string]; process.versions.bun = '1.0.13' satisfies Process['versions'][string]; - Reflect.set(process, 'revision', 'b63fc096bf5bcab16a8a8624fda6a7c79002e428' satisfies Process['revision']); + Reflect.set(process, 'revision', '6f01ddc38deee8f3900bf34b2e3fd1c9178cec8f' satisfies Process['revision']); /** @end_generated_code */ // Doesn't work on Windows sadly diff --git a/packages/bun-polyfills/src/modules/bun.ts b/packages/bun-polyfills/src/modules/bun.ts index 602c7e5064..8e2dd4a60f 100644 --- a/packages/bun-polyfills/src/modules/bun.ts +++ b/packages/bun-polyfills/src/modules/bun.ts @@ -48,7 +48,7 @@ export const main = path.resolve(process.cwd(), process.argv[1] ?? 'repl') satis //? These are automatically updated on build by tools/updateversions.ts, do not edit manually. export const version = '1.0.13' satisfies typeof Bun.version; -export const revision = 'b63fc096bf5bcab16a8a8624fda6a7c79002e428' satisfies typeof Bun.revision; +export const revision = '6f01ddc38deee8f3900bf34b2e3fd1c9178cec8f' satisfies typeof Bun.revision; export const gc = ( globalThis.gc @@ -239,10 +239,8 @@ export const inflateSync = zlib.inflateSync satisfies typeof Bun.inflateSync; export const which = ((cmd: string, options) => { const opts: npm_which.Options = { all: false, nothrow: true }; if (options?.PATH) opts.path = options.PATH; - const result = npm_which.sync(cmd, opts) as string | null; - if (!result || !options?.cwd) return result; - if (path.normalize(result).includes(path.normalize(options.cwd))) return result; - else return null; + if (options?.cwd) opts.path = opts.path ? `${options.cwd}:${opts.path}` : options.cwd; + return npm_which.sync(cmd, opts) as string | null; }) satisfies typeof Bun.which; export const spawn = ((...args) => { diff --git a/packages/bun-polyfills/tools/bun_test_loader.mjs b/packages/bun-polyfills/tools/bun_test_loader.mjs index 79a6eb813f..6ffaf995cc 100644 --- a/packages/bun-polyfills/tools/bun_test_loader.mjs +++ b/packages/bun-polyfills/tools/bun_test_loader.mjs @@ -121,7 +121,7 @@ export async function load(url, context, nextLoad) { } const jsSrc = decoder.decode(transform.files[0].data); // For debugging purposes: - if (process.env.BUN_POLYFILLS_DUMP_TEST_TRANSFORMS) + if (process.env.BUN_POLYFILLS_DUMP_TEST_JS) fs.writeFileSync(`/tmp/bun-polyfills-testrunner-transformed--${url.split('/').at(-1)}.js`, jsSrc); return { shortCircuit: true, diff --git a/packages/bun-polyfills/tools/test_all.js b/packages/bun-polyfills/tools/test_all.js index 02a0f52509..d839ad34b6 100644 --- a/packages/bun-polyfills/tools/test_all.js +++ b/packages/bun-polyfills/tools/test_all.js @@ -39,6 +39,7 @@ await import('../../../test/js/bun/util/peek.test.ts'); await import('../../../test/js/bun/util/readablestreamtoarraybuffer.test.ts'); await import('../../../test/js/bun/util/sleepSync.test.ts'); await import('../../../test/js/bun/util/unsafe.test.js'); +await import('../../../test/js/bun/util/which.test.ts'); // websocket // globals