Debian Codegraph @

packages/babel-helper-plugin-test-runner/src/index.ts

raw
1 import testRunner from "@babel/helper-transform-fixture-test-runner";
2 import path from "path";
3 import { URL } from "url";
4
5 export default function (loc: string) {
6 if (!process.env.BABEL_8_BREAKING) {
7 if (!loc.startsWith("file://")) {
8 const name = path.basename(path.dirname(loc));
9 testRunner(loc + "/fixtures", name);
10 return;
11 }
12 }
13
14 let fixtures = new URL("./fixtures", loc).pathname;
15 if (process.platform === "win32") {
16 // Remove the leading / before the drive letter
17 // TODO: After dropping Node.js 10 support, use fileURLToPath
18 fixtures = fixtures.slice(1);
19 }
20
21 const name = path.basename(new URL("..", loc).pathname);
22
23 testRunner(fixtures, name);
24 }