/
index.js
29 lines (24 loc) 路 914 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import testRunner from "@babel/helper-transform-fixture-test-runner";
import path from "path";
import { URL } from "url";
// Workaround for https://github.com/facebook/jest/issues/11434
import "../../babel-helper-create-class-features-plugin/lib/index.js";
import "../../babel-template/lib/index.js";
import "../../babel-core/lib/index.js";
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);
}