* Lint against CJS globals in modules * Use `import.meta.url` instead of `__filename` in `src` files * Prepare fixtures runner for `import.meta.url` * Use `import.meta.url` instead of `__filename` in `test/index` files * Remove `__dirname` from remaining test files dirname * Avoid using `module` in `src` files * Avoid using `require` in `src` files * Avoid using `require` in `test` files * Update `@types/node` * Compile dynamic import in `@babel/node` * Fix windows * Use `@babel/plugin-proposal-dynamic-import` from npm
25 lines
694 B
JavaScript
25 lines
694 B
JavaScript
import testRunner from "@babel/helper-transform-fixture-test-runner";
|
|
import path from "path";
|
|
import { URL } from "url";
|
|
|
|
export default function (loc) {
|
|
if (!process.env.BABEL_8_BREAKING) {
|
|
if (!loc.startsWith("file://")) {
|
|
const name = path.basename(path.dirname(loc));
|
|
testRunner(loc + "/fixtures", name);
|
|
return;
|
|
}
|
|
}
|
|
|
|
let fixtures = new URL("./fixtures", loc).pathname;
|
|
if (process.platform === "win32") {
|
|
// Remove the leading / before the drive letter
|
|
// TODO: After dropping Node.js 10 support, use fileURLToPath
|
|
fixtures = fixtures.slice(1);
|
|
}
|
|
|
|
const name = path.basename(new URL("..", loc).pathname);
|
|
|
|
testRunner(fixtures, name);
|
|
}
|