aboutsummaryrefslogtreecommitdiff
path: root/test/cli/run/require-cache-fixture.cjs
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-06-01 18:04:09 -0700
committerGravatar GitHub <noreply@github.com> 2023-06-01 18:04:09 -0700
commit3e84f18cc03a6bab898235ff2a9827b47a83aac9 (patch)
tree160b0bd3cf1b707bf68f500f0a82e85807a0fa99 /test/cli/run/require-cache-fixture.cjs
parent42606d6aed323fa24b6783b24624e9f57cb9ef9d (diff)
downloadbun-3e84f18cc03a6bab898235ff2a9827b47a83aac9.tar.gz
bun-3e84f18cc03a6bab898235ff2a9827b47a83aac9.tar.zst
bun-3e84f18cc03a6bab898235ff2a9827b47a83aac9.zip
Implement `__dirname` and `__filename`, allow direct eval in CommonJS (#3164)
* Implement `__dirname` and `__filename`, allow direct eval in CommonJS * Fixup dirname and add test --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test/cli/run/require-cache-fixture.cjs')
-rw-r--r--test/cli/run/require-cache-fixture.cjs14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/cli/run/require-cache-fixture.cjs b/test/cli/run/require-cache-fixture.cjs
index 012f60589..b04e751ac 100644
--- a/test/cli/run/require-cache-fixture.cjs
+++ b/test/cli/run/require-cache-fixture.cjs
@@ -1,6 +1,18 @@
-// So it could be run in Node.js
+// This fixture is intended to be able to run in both Node.js and Bun
const Bun = (globalThis.Bun ??= { gc() {} });
+const { resolve } = require("path");
+
+if (__filename !== resolve(module.filename)) {
+ console.error(__filename, module.id);
+ throw new Error("__filename !== module.id");
+}
+
+if (__dirname !== resolve(module.filename, "../")) {
+ console.error(__filename, module.id);
+ throw new Error("__dirname !== module.filename");
+}
+
const foo = require("./require-cache-fixture-b.cjs");
exports.foo = foo;