Skip to content

Commit

Permalink
Add win32 path.toNamespacedPath and align rest of node:path with Node
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Feb 3, 2024
1 parent c75e768 commit 5e4a05c
Show file tree
Hide file tree
Showing 29 changed files with 4,826 additions and 1,948 deletions.
4 changes: 1 addition & 3 deletions src/bun.js/bindings/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ JSC_DEFINE_HOST_FUNCTION(Path_functionResolve,
JSC_DEFINE_HOST_FUNCTION(Path_functionToNamespacedPath,
(JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
// TODO:
return JSC::JSValue::encode(callFrame->argument(0));
DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__toNamespacedPath);
}

static JSC::JSObject* createPath(JSGlobalObject* globalThis, bool isWindows)
Expand Down
1 change: 1 addition & 0 deletions src/bun.js/bindings/headers.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3,244 changes: 2,781 additions & 463 deletions src/bun.js/node/types.zig

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/js/node/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function bound(obj) {
delimiter: obj.delimiter,
win32: undefined,
posix: undefined,
// Legacy internal API, docs-only deprecated: DEP0080
_makeLong: toNamespacedPath,
};
return result;
Expand Down
16 changes: 8 additions & 8 deletions test/bundler/__snapshots__/bun-build-api.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
// Bun Snapshot v1, https://goo.gl/fbAQLP

exports[`Bun.build BuildArtifact properties: hash 1`] = `"e4885a8bc2de343a"`;

exports[`Bun.build BuildArtifact properties + entry.naming: hash 1`] = `"cb8abf3391c2971f"`;

exports[`Bun.build BuildArtifact properties sourcemap: hash index.js 1`] = `"e4885a8bc2de343a"`;

exports[`Bun.build BuildArtifact properties sourcemap: hash index.js.map 1`] = `"0000000000000000"`;

exports[`Bun.build Bun.write(BuildArtifact) 1`] = `
"var __defProp = Object.defineProperty;
var __export = (target, all) => {
Expand Down Expand Up @@ -80,6 +72,14 @@ NS.then(({ fn: fn2 }) => {
"
`;

exports[`Bun.build BuildArtifact properties: hash 1`] = `"e4885a8bc2de343a"`;

exports[`Bun.build BuildArtifact properties + entry.naming: hash 1`] = `"cb8abf3391c2971f"`;

exports[`Bun.build BuildArtifact properties sourcemap: hash index.js 1`] = `"e4885a8bc2de343a"`;

exports[`Bun.build BuildArtifact properties sourcemap: hash index.js.map 1`] = `"0000000000000000"`;

exports[`Bun.build new Response(BuildArtifact) sets content type: response text 1`] = `
"var __defProp = Object.defineProperty;
var __export = (target, all) => {
Expand Down
2 changes: 1 addition & 1 deletion test/bundler/expectBundled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ function expectBundled(
outputPaths = (
outputPaths
? outputPaths.map(file => path.join(root, file))
: entryPaths.map(file => path.join(outdir!, path.basename(file)))
: entryPaths.map(file => path.join(outdir || "", path.basename(file)))
).map(x => x.replace(/\.ts$/, ".js"));

if (cjs2esm && !outfile && !minifySyntax && !minifyWhitespace) {
Expand Down
10 changes: 5 additions & 5 deletions test/js/bun/ffi/ffi.test.fixture.callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#define IS_CALLBACK 1
// This file is part of Bun!
// You can find the original source:
// https://github.com/oven-sh/bun/blob/main/src/bun.js/api/FFI.h#L2
// https://github.com/oven-sh/bun/blob/main/src/bun.js/api/FFI.h
//
// clang-format off
// This file is only compatible with 64 bit CPUs
// It must be kept in sync with JSCJSValue.h
// https://github.com/oven-sh/WebKit/blob/72c2052b781cbfd4af867ae79ac9de460e392fba/Source/JavaScriptCore/runtime/JSCJSValue.h#L455-L458
// https://github.com/oven-sh/WebKit/blob/main/Source/JavaScriptCore/runtime/JSCJSValue.h
#ifdef IS_CALLBACK
#define INJECT_BEFORE int c = 500; // This is a callback, so we need to inject code before the call
#endif
Expand Down Expand Up @@ -292,10 +292,10 @@ ZIG_REPR_TYPE JSFunctionCall(void* jsGlobalObject, void* callFrame);


/* --- The Callback Function */
/* --- The Callback Function */
bool my_callback_function(void* arg0);

bool my_callback_function(void* arg0) {
#ifdef INJECT_BEFORE
INJECT_BEFORE;
#endif
ZIG_REPR_TYPE arguments[1];
arguments[0] = PTR_TO_JSVALUE(arg0).asZigRepr;
return (bool)JSVALUE_TO_BOOL(_FFI_Callback_call((void*)0x0000000000000000ULL, 1, arguments));
Expand Down
4 changes: 2 additions & 2 deletions test/js/bun/ffi/ffi.test.fixture.receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#define USES_FLOAT 1
// This file is part of Bun!
// You can find the original source:
// https://github.com/oven-sh/bun/blob/main/src/bun.js/api/FFI.h#L2
// https://github.com/oven-sh/bun/blob/main/src/bun.js/api/FFI.h
//
// clang-format off
// This file is only compatible with 64 bit CPUs
// It must be kept in sync with JSCJSValue.h
// https://github.com/oven-sh/WebKit/blob/72c2052b781cbfd4af867ae79ac9de460e392fba/Source/JavaScriptCore/runtime/JSCJSValue.h#L455-L458
// https://github.com/oven-sh/WebKit/blob/main/Source/JavaScriptCore/runtime/JSCJSValue.h
#ifdef IS_CALLBACK
#define INJECT_BEFORE int c = 500; // This is a callback, so we need to inject code before the call
#endif
Expand Down
Loading

0 comments on commit 5e4a05c

Please sign in to comment.