diff --git a/src/env_loader.zig b/src/env_loader.zig index 630a262688..b4f2448a95 100644 --- a/src/env_loader.zig +++ b/src/env_loader.zig @@ -1351,7 +1351,7 @@ pub fn jsFunctionProcessLoadEnvFile(globalObject: *jsc.JSGlobalObject, callframe }; defer bun.default_allocator.free(source.contents); - // Create a temporary map for parsing - using VM allocator instead + // Create a temporary map for parsing - using VM allocator instead var env_map = Map.init(vm.allocator); defer env_map.map.deinit(); @@ -1383,6 +1383,11 @@ pub const home_env = if (Environment.isWindows) "USERPROFILE" else "HOME"; const string = []const u8; +// Export the function for C binding +comptime { + @export(&jsc.toJSHostFn(jsFunctionProcessLoadEnvFile), .{ .name = "jsFunctionProcessLoadEnvFile" }); +} + const Fs = @import("./fs.zig"); const std = @import("std"); const URL = @import("./url.zig").URL; @@ -1393,13 +1398,8 @@ const Environment = bun.Environment; const OOM = bun.OOM; const Output = bun.Output; const analytics = bun.analytics; +const jsc = bun.jsc; const logger = bun.logger; const s3 = bun.S3; const strings = bun.strings; const api = bun.schema.api; -const jsc = bun.jsc; - -// Export the function for C binding -comptime { - @export(&jsc.toJSHostFn(jsFunctionProcessLoadEnvFile), .{ .name = "jsFunctionProcessLoadEnvFile" }); -} diff --git a/test/js/node/process/process-loadenvfile.test.ts b/test/js/node/process/process-loadenvfile.test.ts index 0a091cedc1..3c970c9938 100644 --- a/test/js/node/process/process-loadenvfile.test.ts +++ b/test/js/node/process/process-loadenvfile.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "bun:test"; -import { writeFileSync, unlinkSync } from "fs"; -import { join } from "path"; +import { unlinkSync, writeFileSync } from "fs"; import { tmpdir } from "os"; +import { join } from "path"; describe("process.loadEnvFile", () => { it("should load environment variables from a .env file", () => { @@ -53,7 +53,7 @@ FULL_URL=\${API_URL}/v1 expect(result).toEqual({ BASE_URL: "https://example.com", - API_URL: "https://example.com/api", + API_URL: "https://example.com/api", FULL_URL: "https://example.com/api/v1", }); } finally { @@ -131,4 +131,4 @@ BAZ=qux process.loadEnvFile(123); }).toThrow(); }); -}); \ No newline at end of file +});