diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 5275154e..d37952ea 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -15,7 +15,8 @@ jobs: strategy: matrix: - node-version: [16.x] + node-version: [16.x, 18.x, 19.x] + fail-fast: false steps: - uses: actions/checkout@v3 diff --git a/test/Test.mjs b/test/Test.mjs index 82b18628..e5481d6b 100644 --- a/test/Test.mjs +++ b/test/Test.mjs @@ -5,9 +5,7 @@ import * as Path from "path"; import * as Curry from "rescript/lib/es6/curry.js"; import * as CodeFrame from "@babel/code-frame"; -var dirname = typeof __dirname === "undefined" ? undefined : __dirname; - -var dirname$1 = dirname !== undefined ? dirname : ""; +var dirname = (new URL('.', import.meta.url).pathname); function cleanUpStackTrace(stack) { var removeInternalLines = function (lines, _i) { @@ -35,7 +33,7 @@ function run(loc, left, comparator, right) { var match = loc[0]; var line = match[1]; var file = match[0]; - var fileContent = Fs.readFileSync(Path.join(dirname$1, file), { + var fileContent = Fs.readFileSync(Path.join(dirname, file), { encoding: "utf-8" }); var left$1 = JSON.stringify(left); @@ -55,7 +53,7 @@ function run(loc, left, comparator, right) { } export { - dirname$1 as dirname, + dirname , cleanUpStackTrace , run , } diff --git a/test/Test.res b/test/Test.res index 10de0cf6..e229eb1f 100644 --- a/test/Test.res +++ b/test/Test.res @@ -9,10 +9,7 @@ external codeFrameColumns: (string, {..}, {..}) => string = "codeFrameColumns" @module("fs") @val external readFileSync: (string, {..}) => string = "readFileSync" @module("path") @val external join: (string, string) => string = "join" -let dirname = switch %external(__dirname) { -| None => "" -| Some(dirname) => dirname -} +let dirname = %raw("new URL('.', import.meta.url).pathname") let cleanUpStackTrace = stack => { // Stack format: https://nodejs.org/api/errors.html#errors_error_stack