polyfills: fix which options.cwd handling

This commit is contained in:
jhmaster2000
2023-12-08 15:46:29 -03:00
parent 6f01ddc38d
commit aa606b23df
4 changed files with 6 additions and 7 deletions

View File

@@ -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

View File

@@ -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) => {

View File

@@ -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,

View File

@@ -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