Debian Codegraph @

packages/babel-helper-fixtures/src/index.ts

raw symbols SCIP
1 import semver from "semver";
2 import path from "path";
3 import fs from "fs";
4 import { fileURLToPath } from "url";
5 import { createRequire } from "module";
6 import type { InputOptionsscip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/InputOptions# } from "@babel/core"scip-typescript npm @babel/core 7.20.12 src/`index.ts`/;
7 import type { EncodedSourceMap } from "@jridgewell/gen-mapping";
8
9 const requirescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/require. = createRequire(import.meta.urlscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/ImportMeta#url.);
10
11 const nodeVersionscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/nodeVersion. = semver.clean(process.version.slice(1));
12
13 function humanizescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/humanize().(valscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/humanize().(val): string, noextscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/humanize().(noext)?: boolean) {
14 if (noextscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/humanize().(noext)) valscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/humanize().(val) = path.basename(valscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/humanize().(val), path.extname(valscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/humanize().(val)));
15 return valscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/humanize().(val).replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().(/-/g, " ");
16 }
17
18 interface TestIOscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO# {
19 locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.: string;
20 codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.: string;
21 }
22
23 export interface TestFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile# extends TestIOscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO# {
24 filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#filename.: string;
25 }
26
27 export interface Testscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test# {
28 taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#taskDir.: string;
29 titlescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#title.: string;
30 disabledscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#disabled.: boolean;
31 optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options.: TaskOptionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#;
32 optionsDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#optionsDir.: string;
33 doNotSetSourceTypescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#doNotSetSourceType.: boolean;
34 externalHelpersscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#externalHelpers.: boolean;
35 ignoreOutputscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#ignoreOutput.: boolean;
36 stdoutscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#stdout.: TestIOscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#;
37 stderrscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#stderr.: TestIOscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#;
38 execscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#exec.: TestFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#;
39 actualscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#actual.: TestFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#;
40 expectscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#expect.: TestFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#;
41 inputSourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#inputSourceMap.?: EncodedSourceMap;
42 sourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMap.: string;
43 sourceMapFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMapFile.: TestFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#;
44 validateLogsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#validateLogs.: boolean;
45 }
46
47 export interface TaskOptionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions# extends InputOptionsscip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/InputOptions# {
48 BABEL_8_BREAKINGscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#BABEL_8_BREAKING.?: boolean;
49 DO_NOT_SET_SOURCE_TYPEscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#DO_NOT_SET_SOURCE_TYPE.?: boolean;
50 externalHelpersscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#externalHelpers.?: boolean;
51 ignoreOutputscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#ignoreOutput.?: boolean;
52 minNodeVersionscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#minNodeVersion.?: string;
53 sourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#sourceMap.?: boolean;
54 osscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#os.?: string | string[];
55 validateLogsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#validateLogs.?: boolean;
56 throwsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#throws.?: boolean | string;
57 }
58
59 type Suitescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite# = {
60 optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#typeLiteral6:options.: TaskOptionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#;
61 testsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#typeLiteral6:tests.: Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<Testscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#>;
62 titlescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#typeLiteral6:title.: string;
63 filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#typeLiteral6:filename.: string;
64 };
65
66 function tryResolvescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/tryResolve().(modulescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/tryResolve().(module): string) {
67 try {
68 return requirescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/require..resolve(modulescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/tryResolve().(module));
69 } catch (e) {
70 return null;
71 }
72 }
73 function assertDirectoryscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/assertDirectory().(locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/assertDirectory().(loc): string) {
74 if (!fs.statSync(locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/assertDirectory().(loc)).isDirectory()) {
75 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(`Expected ${locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/assertDirectory().(loc)} to be a directory.`);
76 }
77 }
78
79 function shouldIgnorescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(namescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(name): string, ignorescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(ignore)?: Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<string>) {
80 if (ignorescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(ignore) && ignorescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(ignore).indexOfscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#indexOf().(namescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(name)) >= 0) {
81 return true;
82 }
83
84 const ext = path.extname(namescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(name));
85 const base = path.basename(namescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(name), ext);
86
87 return (
88 namescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(name)[0] === "." ||
89 ext === ".md" ||
90 base === "LICENSE" ||
91 base === "options" ||
92 namescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(name) === "package.json"
93 );
94 }
95
96 const EXTENSIONSscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/EXTENSIONS. = [".js", ".mjs", ".ts", ".tsx", ".cts", ".mts"];
97
98 function findFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/findFile().(filepathscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/findFile().(filepath): string, allowJSONscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/findFile().(allowJSON)?: boolean) {
99 const matches = [];
100
101 for (const ext of EXTENSIONSscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/EXTENSIONS..concatscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#concat().(allowJSONscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/findFile().(allowJSON) ? ".json" : [])) {
102 const name = filepathscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/findFile().(filepath) + ext;
103
104 if (fs.existsSync(name)) matches.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(name);
105 }
106
107 if (matches.lengthscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#length. > 1) {
108 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(`Found conflicting file matches: ${matches.joinscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#join().(", ")}`);
109 }
110
111 return matches[0];
112 }
113
114 function pushTaskscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(
115 taskNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskName): string,
116 taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir): string,
117 suitescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(suite): Suitescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#,
118 suiteNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(suiteName): string,
119 ) {
120 const taskDirStats = fs.statSync(taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir));
121 let actualLoc = findFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/findFile().(taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/input");
122 let execLoc = findFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/findFile().(taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/exec");
123
124 // If neither input nor exec is present it is not a real testcase
125 if (taskDirStats.isDirectory() && !actualLoc && !execLoc) {
126 if (fs.readdirSync(taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir)).length > 0) {
127 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..warnscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#warn().(`Skipped test folder with invalid layout: ${taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir)}`);
128 }
129 return;
130 } else if (!actualLoc) {
131 actualLoc = taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/input.js";
132 } else if (!execLoc) {
133 execLoc = taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/exec.js";
134 }
135
136 const expectLoc =
137 findFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/findFile().(taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/output", true /* allowJSON */) ||
138 findFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/findFile().(`${taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir)}/output.extended`, true) ||
139 taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/output.js";
140 const stdoutLoc = taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/stdout.txt";
141 const stderrLoc = taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/stderr.txt";
142
143 const actualLocAlias =
144 suiteNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(suiteName) + "/" + taskNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskName) + "/" + path.basename(actualLoc);
145 const expectLocAlias =
146 suiteNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(suiteName) + "/" + taskNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskName) + "/" + path.basename(actualLoc);
147 let execLocAlias =
148 suiteNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(suiteName) + "/" + taskNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskName) + "/" + path.basename(actualLoc);
149
150 if (taskDirStats.isFile()) {
151 const ext = path.extname(taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir));
152 if (EXTENSIONSscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/EXTENSIONS..indexOfscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#indexOf().(ext) === -1) return;
153
154 execLoc = taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir);
155 execLocAlias = suiteNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(suiteName) + "/" + taskNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskName);
156 }
157
158 const taskOpts: TaskOptionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions# = JSONscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#.parsescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#parse().(JSONscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#.stringifyscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#stringify().(suitescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(suite).optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#typeLiteral6:options.));
159
160 const taskOptsLoc = tryResolvescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/tryResolve().(taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/options");
161 if (taskOptsLoc) Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.assignscip-typescript npm typescript 5.9.3 lib/`lib.es2015.core.d.ts`/ObjectConstructor#assign().(taskOpts, requirescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/require.(taskOptsLoc));
162
163 const test: Testscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test# = {
164 taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#taskDir.,
165 optionsDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#optionsDir.: taskOptsLoc ? path.dirname(taskOptsLoc) : null,
166 titlescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#title.: humanizescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/humanize().(taskNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskName), true),
167 disabledscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#disabled.:
168 taskNamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskName)[0] === "." ||
169 (process.env.BABEL_8_BREAKING
170 ? taskOpts.BABEL_8_BREAKINGscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#BABEL_8_BREAKING. === false
171 : taskOpts.BABEL_8_BREAKINGscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#BABEL_8_BREAKING. === true),
172 optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options.: taskOpts,
173 doNotSetSourceTypescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#doNotSetSourceType.: taskOpts.DO_NOT_SET_SOURCE_TYPEscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#DO_NOT_SET_SOURCE_TYPE.,
174 externalHelpersscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#externalHelpers.:
175 taskOpts.externalHelpersscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#externalHelpers. ??
176 !!tryResolvescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/tryResolve().("@babel/plugin-external-helpers"),
177 validateLogsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#validateLogs.: taskOpts.validateLogsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#validateLogs.,
178 ignoreOutputscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#ignoreOutput.: taskOpts.ignoreOutputscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#ignoreOutput.,
179 stdoutscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#stdout.: { locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.: stdoutLoc, codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.: readFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(stdoutLoc) },
180 stderrscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#stderr.: { locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.: stderrLoc, codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.: readFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(stderrLoc) },
181 execscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#exec.: {
182 locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.: execLoc,
183 codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.: readFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(execLoc),
184 filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#filename.: execLocAlias,
185 },
186 actualscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#actual.: {
187 locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.: actualLoc,
188 codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.: readFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(actualLoc),
189 filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#filename.: actualLocAlias,
190 },
191 expectscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#expect.: {
192 locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.: expectLoc,
193 codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.: readFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(expectLoc),
194 filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#filename.: expectLocAlias,
195 },
196 sourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMap.: undefined,
197 sourceMapFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMapFile.: undefined,
198 inputSourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#inputSourceMap.: undefined,
199 };
200
201 delete taskOpts.BABEL_8_BREAKINGscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#BABEL_8_BREAKING.;
202 delete taskOpts.DO_NOT_SET_SOURCE_TYPEscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#DO_NOT_SET_SOURCE_TYPE.;
203
204 // If there's node requirement, check it before pushing task
205 if (taskOpts.minNodeVersionscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#minNodeVersion.) {
206 const minimumVersion = semver.clean(taskOpts.minNodeVersionscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#minNodeVersion.);
207
208 if (minimumVersion == null) {
209 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
210 `'minNodeVersion' has invalid semver format: ${taskOpts.minNodeVersionscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#minNodeVersion.}`,
211 );
212 }
213
214 if (semver.lt(nodeVersionscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/nodeVersion., minimumVersion)) {
215 return;
216 }
217
218 // Delete to avoid option validation error
219 delete taskOpts.minNodeVersionscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#minNodeVersion.;
220 }
221
222 if (taskOpts.osscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#os.) {
223 let os = taskOpts.osscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#os.;
224
225 if (!Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#.isArrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ArrayConstructor#isArray().(os) && typeof os !== "string") {
226 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
227 `'os' should be either string or string array: ${taskOpts.osscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#os.}`,
228 );
229 }
230
231 if (typeof os === "string") {
232 os = [os];
233 }
234
235 if (!os.includesscip-typescript npm typescript 5.9.3 lib/`lib.es2016.array.include.d.ts`/Array#includes().(process.platform)) {
236 return;
237 }
238
239 delete taskOpts.osscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#os.;
240 }
241
242 // traceur checks
243
244 if (test.execscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#exec..codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code..indexOfscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#indexOf().("// Async.") >= 0) {
245 return;
246 }
247
248 suitescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(suite).testsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#typeLiteral6:tests..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(test);
249
250 const sourceMapLoc = taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/source-map.json";
251 if (fs.existsSync(sourceMapLoc)) {
252 test.sourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMap. = JSONscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#.parsescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#parse().(readFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(sourceMapLoc));
253 }
254 test.sourceMapFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMapFile. = {
255 locscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#loc.: sourceMapLoc,
256 codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.: test.sourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMap.,
257 filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestFile#filename.: "",
258 };
259
260 const inputMapLoc = taskDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskDir) + "/input-source-map.json";
261 if (fs.existsSync(inputMapLoc)) {
262 test.inputSourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#inputSourceMap. = JSONscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#.parsescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#parse().(readFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(inputMapLoc));
263 }
264
265 if (taskOpts.throwsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#throws.) {
266 if (test.expectscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#expect..codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.) {
267 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
268 "Test cannot throw and also return output code: " + expectLoc,
269 );
270 }
271 if (test.sourceMapscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#sourceMap.) {
272 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
273 "Test cannot throw and also return sourcemaps: " + sourceMapLoc,
274 );
275 }
276 }
277
278 if (!test.validateLogsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#validateLogs. && (test.stdoutscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#stdout..codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code. || test.stderrscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#stderr..codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.)) {
279 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
280 "stdout.txt and stderr.txt are only allowed when the 'validateLogs' option is enabled: " +
281 (test.stdoutscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#stdout..codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code. ? stdoutLoc : stderrLoc),
282 );
283 }
284 if (test.ignoreOutputscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#ignoreOutput.) {
285 if (test.expectscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#expect..codescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TestIO#code.) {
286 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
287 "Test cannot ignore its output and also validate it: " + expectLoc,
288 );
289 }
290 if (!test.validateLogsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#validateLogs.) {
291 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
292 "ignoreOutput can only be used when validateLogs is true: " +
293 taskOptsLoc,
294 );
295 }
296 }
297
298 // Delete to avoid option validation error
299 delete test.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options..validateLogsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#validateLogs.;
300 delete test.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options..ignoreOutputscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#ignoreOutput.;
301 delete test.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#options..externalHelpersscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions#externalHelpers.;
302 }
303
304 function wrapPackagesArrayscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/wrapPackagesArray().(
305 typescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/wrapPackagesArray().(type): "plugin" | "preset",
306 namesscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/wrapPackagesArray().(names): (string | [string, object?, string?])[],
307 optionsDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/wrapPackagesArray().(optionsDir): string,
308 ) {
309 return namesscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/wrapPackagesArray().(names).mapscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#map().(function (val) {
310 if (typeof val === "string") val = [val];
311
312 // relative path (outside of monorepo)
313 if (val[0][0] === ".") {
314 if (!optionsDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/wrapPackagesArray().(optionsDir)) {
315 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
316 "Please provide an options.json in test dir when using a " +
317 "relative plugin path.",
318 );
319 }
320
321 val[0] = path.resolve(optionsDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/wrapPackagesArray().(optionsDir), val[0]);
322 } else {
323 let name = val[0];
324 const match = name.matchscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#match().(/^(@babel\/(?:plugin-|preset-)?)(.*)$/);
325 if (match) {
326 name = match[2];
327 }
328
329 const monorepoPath = path.join(
330 path.dirname(fileURLToPath(import.meta.urlscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/ImportMeta#url.)),
331 "../../..",
332 name.startsWithscip-typescript npm typescript 5.9.3 lib/`lib.es2015.core.d.ts`/String#startsWith().("codemod") ? "codemods" : "packages",
333 `babel-${typescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/wrapPackagesArray().(type)}-${name}/lib/index.js`,
334 );
335
336 if (fs.existsSync(monorepoPath)) {
337 if (match) {
338 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
339 `Remove the "${match[1]}" prefix from "${val[0]}", to load it from the monorepo`,
340 );
341 }
342
343 val[0] = monorepoPath;
344 }
345 }
346
347 return val;
348 });
349 }
350
351 /**
352 * Resolve plugins/presets defined in options.json
353 *
354 * @export
355 * @param {{}} options the imported options.json
356 * @param {string} optionsDir the direcotry where options.json is placed
357 * @returns {{}} options whose plugins/presets are resolved
358 */
359 export function resolveOptionPluginOrPresetscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(
360 optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(options): any,
361 optionsDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(optionsDir): string,
362 ): {} {
363 if (optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(options).plugins) {
364 optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(options).plugins = wrapPackagesArrayscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/wrapPackagesArray().("plugin", optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(options).plugins, optionsDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(optionsDir));
365 }
366 if (optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(options).presets) {
367 optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(options).presets = wrapPackagesArrayscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/wrapPackagesArray().(
368 "preset",
369 optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(options).presets,
370 optionsDirscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(optionsDir),
371 ).mapscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#map().(function (val) {
372 if (val.length > 3) {
373 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
374 "Unexpected extra options " +
375 JSONscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#.stringifyscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#stringify().(val.slicescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#slice().(3)) +
376 " passed to preset.",
377 );
378 }
379
380 return val;
381 });
382 }
383 return optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(options);
384 }
385
386 export default function getscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/get().(entryLocscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/get().(entryLoc): string): Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<Suitescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Suite#> {
387 const suites = [];
388
389 let rootOpts: TaskOptionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/TaskOptions# = {};
390 const rootOptsLoc = tryResolvescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/tryResolve().(entryLocscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/get().(entryLoc) + "/options");
391 if (rootOptsLoc) rootOpts = requirescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/require.(rootOptsLoc);
392
393 for (const suiteName of fs.readdirSync(entryLocscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/get().(entryLoc))) {
394 if (shouldIgnorescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(suiteName)) continue;
395
396 const suite = {
397 optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/options0:: { ...rootOpts },
398 testsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/tests0:: [] as Testscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/Test#[],
399 titlescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/title0:: humanizescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/humanize().(suiteName),
400 filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/filename0:: entryLocscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/get().(entryLoc) + "/" + suiteName,
401 };
402
403 assertDirectoryscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/assertDirectory().(suite.filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/filename0:);
404 suites.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(suite);
405
406 const suiteOptsLoc = tryResolvescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/tryResolve().(suite.filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/filename0: + "/options");
407 if (suiteOptsLoc) {
408 suite.optionsscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/options0: = resolveOptionPluginOrPresetscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/resolveOptionPluginOrPreset().(
409 requirescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/require.(suiteOptsLoc),
410 suite.filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/filename0:,
411 );
412 }
413
414 for (const taskName of fs.readdirSync(suite.filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/filename0:)) {
415 pushTaskscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/pushTask().(taskName, suite.filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/filename0: + "/" + taskName, suite, suiteName);
416 }
417 }
418
419 return suites;
420 }
421
422 export function multiplescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/multiple().(entryLocscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/multiple().(entryLoc): string, ignorescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/multiple().(ignore)?: Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<string>) {
423 const categories: Recordscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Record#<string, unknown> = {};
424
425 for (const name of fs.readdirSync(entryLocscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/multiple().(entryLoc))) {
426 if (shouldIgnorescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/shouldIgnore().(name, ignorescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/multiple().(ignore))) continue;
427
428 const loc = path.join(entryLocscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/multiple().(entryLoc), name);
429 assertDirectoryscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/assertDirectory().(loc);
430
431 categories[name] = getscip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/get().(loc);
432 }
433
434 return categories;
435 }
436
437 export function readFilescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(filename): string) {
438 if (fs.existsSync(filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(filename))) {
439 let file = fs.readFileSync(filenamescip-typescript npm @babel/helper-fixtures 7.19.4 src/`index.ts`/readFile().(filename), "utf8").trimRight();
440 file = file.replace(/\r\n/g, "\n");
441 return file;
442 } else {
443 return "";
444 }
445 }