Update ava to 4.3.3
The [release notes](https://github.com/avajs/ava/releases/tag/v4.3.3) mention compatibility with Node 18.8.
This commit is contained in:
parent
21530f507f
commit
bea5e4b220
160 changed files with 2647 additions and 2263 deletions
12
node_modules/ava/lib/api.js
generated
vendored
12
node_modules/ava/lib/api.js
generated
vendored
|
|
@ -177,13 +177,19 @@ export default class Api extends Emittery {
|
|||
const fileCount = selectedFiles.length;
|
||||
|
||||
// The files must be in the same order across all runs, so sort them.
|
||||
selectedFiles = selectedFiles.sort((a, b) => a.localeCompare(b, [], {numeric: true}));
|
||||
const defaultComparator = (a, b) => a.localeCompare(b, [], {numeric: true});
|
||||
selectedFiles = selectedFiles.sort(this.options.sortTestFiles || defaultComparator);
|
||||
selectedFiles = chunkd(selectedFiles, currentIndex, totalRuns);
|
||||
|
||||
const currentFileCount = selectedFiles.length;
|
||||
|
||||
runStatus = new RunStatus(fileCount, {currentFileCount, currentIndex, totalRuns}, selectionInsights);
|
||||
} else {
|
||||
// If a custom sorter was configured, use it.
|
||||
if (this.options.sortTestFiles) {
|
||||
selectedFiles = selectedFiles.sort(this.options.sortTestFiles);
|
||||
}
|
||||
|
||||
runStatus = new RunStatus(selectedFiles.length, null, selectionInsights);
|
||||
}
|
||||
|
||||
|
|
@ -261,8 +267,8 @@ export default class Api extends Emittery {
|
|||
}
|
||||
|
||||
const lineNumbers = getApplicableLineNumbers(globs.normalizeFileForMatching(apiOptions.projectDir, file), filter);
|
||||
// Removing `providers` field because they cannot be transfered to the worker threads.
|
||||
const {providers, ...forkOptions} = apiOptions;
|
||||
// Removing `providers` and `sortTestFiles` fields because they cannot be transferred to the worker threads.
|
||||
const {providers, sortTestFiles, ...forkOptions} = apiOptions;
|
||||
const options = {
|
||||
...forkOptions,
|
||||
providerStates,
|
||||
|
|
|
|||
22
node_modules/ava/lib/assert.js
generated
vendored
22
node_modules/ava/lib/assert.js
generated
vendored
|
|
@ -106,10 +106,15 @@ function validateExpectations(assertion, expectations, numberArgs) { // eslint-d
|
|||
});
|
||||
}
|
||||
|
||||
if (hasOwnProperty(expectations, 'message') && typeof expectations.message !== 'string' && !(expectations.message instanceof RegExp)) {
|
||||
if (
|
||||
hasOwnProperty(expectations, 'message')
|
||||
&& typeof expectations.message !== 'string'
|
||||
&& !(expectations.message instanceof RegExp)
|
||||
&& !(typeof expectations.message === 'function')
|
||||
) {
|
||||
throw new AssertionError({
|
||||
assertion,
|
||||
message: `The \`message\` property of the second argument to \`t.${assertion}()\` must be a string or regular expression`,
|
||||
message: `The \`message\` property of the second argument to \`t.${assertion}()\` must be a string, regular expression or a function`,
|
||||
values: [formatWithLabel('Called with:', expectations)],
|
||||
});
|
||||
}
|
||||
|
|
@ -230,6 +235,19 @@ function assertExpectations({assertion, actual, expectations, message, prefix, s
|
|||
});
|
||||
}
|
||||
|
||||
if (typeof expectations.message === 'function' && expectations.message(actual.message) === false) {
|
||||
throw new AssertionError({
|
||||
assertion,
|
||||
message,
|
||||
savedError,
|
||||
actualStack,
|
||||
values: [
|
||||
formatWithLabel(`${prefix} unexpected exception:`, actual),
|
||||
formatWithLabel('Expected message to return true:', expectations.message),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof expectations.code !== 'undefined' && actual.code !== expectations.code) {
|
||||
throw new AssertionError({
|
||||
assertion,
|
||||
|
|
|
|||
30
node_modules/ava/lib/cli.js
generated
vendored
30
node_modules/ava/lib/cli.js
generated
vendored
|
|
@ -21,6 +21,7 @@ import {splitPatternAndLineNumbers} from './line-numbers.js';
|
|||
import {loadConfig} from './load-config.js';
|
||||
import normalizeModuleTypes from './module-types.js';
|
||||
import normalizeNodeArguments from './node-arguments.js';
|
||||
import pkg from './pkg.cjs';
|
||||
import providerManager from './provider-manager.js';
|
||||
import DefaultReporter from './reporters/default.js';
|
||||
import TapReporter from './reporters/tap.js';
|
||||
|
|
@ -102,8 +103,15 @@ export default async function loadCli() { // eslint-disable-line complexity
|
|||
let conf;
|
||||
let confError;
|
||||
try {
|
||||
const {argv: {config: configFile}} = yargs(hideBin(process.argv)).help(false);
|
||||
conf = await loadConfig({configFile});
|
||||
const {argv: {config: configFile}} = yargs(hideBin(process.argv)).help(false).version(false);
|
||||
const loaded = await loadConfig({configFile});
|
||||
if (loaded.unsupportedFiles.length > 0) {
|
||||
console.log(chalk.magenta(
|
||||
` ${figures.warning} AVA does not support JSON config, ignoring:\n\n ${loaded.unsupportedFiles.join('\n ')}`,
|
||||
));
|
||||
}
|
||||
|
||||
conf = loaded.config;
|
||||
if (conf.configFile && path.basename(conf.configFile) !== path.relative(conf.projectDir, conf.configFile)) {
|
||||
console.log(chalk.magenta(` ${figures.warning} Using configuration from ${conf.configFile}`));
|
||||
}
|
||||
|
|
@ -132,6 +140,7 @@ export default async function loadCli() { // eslint-disable-line complexity
|
|||
|
||||
let resetCache = false;
|
||||
const {argv} = yargs(hideBin(process.argv))
|
||||
.version(pkg.version)
|
||||
.parserConfiguration({
|
||||
'boolean-negation': true,
|
||||
'camel-case-expansion': false,
|
||||
|
|
@ -161,7 +170,7 @@ export default async function loadCli() { // eslint-disable-line complexity
|
|||
})
|
||||
.command('* [<pattern>...]', 'Run tests', yargs => yargs.options(FLAGS).positional('pattern', {
|
||||
array: true,
|
||||
describe: 'Select which test files to run. Leave empty if you want AVA to run all test files as per your configuration. Accepts glob patterns, directories that (recursively) contain test files, and file paths. Add a colon and specify line numbers of specific tests to run',
|
||||
describe: 'Select which test files to run. Leave empty if you want AVA to run all test files as per your configuration. Accepts glob patterns, directories that (recursively) contain test files, and file paths optionally suffixed with a colon and comma-separated numbers and/or ranges identifying the 1-based line(s) of specific tests to run',
|
||||
type: 'string',
|
||||
}), argv => {
|
||||
if (activeInspector) {
|
||||
|
|
@ -188,7 +197,7 @@ export default async function loadCli() { // eslint-disable-line complexity
|
|||
},
|
||||
}).positional('pattern', {
|
||||
demand: true,
|
||||
describe: 'Glob patterns to select a single test file to debug. Add a colon and specify line numbers of specific tests to run',
|
||||
describe: 'Glob pattern to select a single test file to debug, optionally suffixed with a colon and comma-separated numbers and/or ranges identifying the 1-based line(s) of specific tests to run',
|
||||
type: 'string',
|
||||
}),
|
||||
argv => {
|
||||
|
|
@ -319,16 +328,20 @@ export default async function loadCli() { // eslint-disable-line complexity
|
|||
exit('’sources’ has been removed. Use ’ignoredByWatcher’ to provide glob patterns of files that the watcher should ignore.');
|
||||
}
|
||||
|
||||
let pkg;
|
||||
if (Reflect.has(conf, 'sortTestFiles') && typeof conf.sortTestFiles !== 'function') {
|
||||
exit('’sortTestFiles’ must be a comparator function.');
|
||||
}
|
||||
|
||||
let projectPackageObject;
|
||||
try {
|
||||
pkg = JSON.parse(fs.readFileSync(path.resolve(projectDir, 'package.json')));
|
||||
projectPackageObject = JSON.parse(fs.readFileSync(path.resolve(projectDir, 'package.json')));
|
||||
} catch (error) {
|
||||
if (error.code !== 'ENOENT') {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const {type: defaultModuleType = 'commonjs'} = pkg || {};
|
||||
const {type: defaultModuleType = 'commonjs'} = projectPackageObject || {};
|
||||
|
||||
const providers = [];
|
||||
if (Reflect.has(conf, 'typescript')) {
|
||||
|
|
@ -380,7 +393,7 @@ export default async function loadCli() { // eslint-disable-line complexity
|
|||
}
|
||||
|
||||
let parallelRuns = null;
|
||||
if (isCi && ciParallelVars) {
|
||||
if (isCi && ciParallelVars && combined.utilizeParallelBuilds !== false) {
|
||||
const {index: currentIndex, total: totalRuns} = ciParallelVars;
|
||||
parallelRuns = {currentIndex, totalRuns};
|
||||
}
|
||||
|
|
@ -411,6 +424,7 @@ export default async function loadCli() { // eslint-disable-line complexity
|
|||
moduleTypes,
|
||||
nodeArguments,
|
||||
parallelRuns,
|
||||
sortTestFiles: conf.sortTestFiles,
|
||||
projectDir,
|
||||
providers,
|
||||
ranFromCli: true,
|
||||
|
|
|
|||
12
node_modules/ava/lib/create-chain.js
generated
vendored
12
node_modules/ava/lib/create-chain.js
generated
vendored
|
|
@ -101,11 +101,13 @@ export default function createChain(fn, defaults, meta) {
|
|||
|
||||
root.meta = meta;
|
||||
|
||||
// Our type definition uses ESM syntax; when using CJS with VSCode, the
|
||||
// auto-completion assumes the root is accessed through `require('ava').default`.
|
||||
// Placate VSCode by adding a mostly hidden default property on the root.
|
||||
// This is available through both CJS and ESM imports. We use a proxy so that
|
||||
// we don't end up with root.default.default.default chains.
|
||||
// The ESM and CJS type definitions export the chain (`test()` function) as
|
||||
// the default. TypeScript's CJS output (when `esModuleInterop` is disabled)
|
||||
// assume `require('ava').default` is available. The same goes for `import ava
|
||||
// = require('ava')` syntax.
|
||||
//
|
||||
// Add `test.default` to make this work. Use a proxy to avoid
|
||||
// `test.default.default` chains.
|
||||
Object.defineProperty(root, 'default', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
|
|
|
|||
2
node_modules/ava/lib/eslint-plugin-helper-worker.js
generated
vendored
2
node_modules/ava/lib/eslint-plugin-helper-worker.js
generated
vendored
|
|
@ -41,7 +41,7 @@ const buildGlobs = ({conf, providers, projectDir, overrideExtensions, overrideFi
|
|||
|
||||
const resolveGlobs = async (projectDir, overrideExtensions, overrideFiles) => {
|
||||
if (!configCache.has(projectDir)) {
|
||||
configCache.set(projectDir, loadConfig({resolveFrom: projectDir}).then(async conf => {
|
||||
configCache.set(projectDir, loadConfig({resolveFrom: projectDir}).then(async ({config: conf}) => {
|
||||
const providers = await collectProviders({conf, projectDir});
|
||||
return {conf, providers};
|
||||
}));
|
||||
|
|
|
|||
33
node_modules/ava/lib/load-config.js
generated
vendored
33
node_modules/ava/lib/load-config.js
generated
vendored
|
|
@ -20,14 +20,15 @@ const importConfig = async ({configFile, fileForErrorMessage}) => {
|
|||
};
|
||||
|
||||
const loadConfigFile = async ({projectDir, configFile}) => {
|
||||
if (!fs.existsSync(configFile)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const fileForErrorMessage = path.relative(projectDir, configFile);
|
||||
try {
|
||||
await fs.promises.access(configFile);
|
||||
return {config: await importConfig({configFile, fileForErrorMessage}), configFile, fileForErrorMessage};
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
return null;
|
||||
}
|
||||
|
||||
throw Object.assign(new Error(`Error loading ${fileForErrorMessage}: ${error.message}`), {parent: error});
|
||||
}
|
||||
};
|
||||
|
|
@ -63,6 +64,20 @@ async function findRepoRoot(fromDir) {
|
|||
return root;
|
||||
}
|
||||
|
||||
async function checkJsonFile(searchDir) {
|
||||
const file = path.join(searchDir, 'ava.config.json');
|
||||
try {
|
||||
await fs.promises.access(file);
|
||||
return file;
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
return null;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadConfig({configFile, resolveFrom = process.cwd(), defaults = {}} = {}) {
|
||||
let packageConf = await packageConfig('ava', {cwd: resolveFrom});
|
||||
const filepath = packageJsonPath(packageConf);
|
||||
|
|
@ -74,6 +89,7 @@ export async function loadConfig({configFile, resolveFrom = process.cwd(), defau
|
|||
const allowConflictWithPackageJson = Boolean(configFile);
|
||||
configFile = resolveConfigFile(configFile);
|
||||
|
||||
const unsupportedFiles = [];
|
||||
let fileConf = NO_SUCH_FILE;
|
||||
let fileForErrorMessage;
|
||||
let conflicting = [];
|
||||
|
|
@ -86,12 +102,17 @@ export async function loadConfig({configFile, resolveFrom = process.cwd(), defau
|
|||
let searchDir = projectDir;
|
||||
const stopAt = path.dirname(repoRoot);
|
||||
do {
|
||||
const results = await Promise.all([ // eslint-disable-line no-await-in-loop
|
||||
const [jsonFile, ...results] = await Promise.all([ // eslint-disable-line no-await-in-loop
|
||||
checkJsonFile(searchDir),
|
||||
loadConfigFile({projectDir, configFile: path.join(searchDir, 'ava.config.js')}),
|
||||
loadConfigFile({projectDir, configFile: path.join(searchDir, 'ava.config.cjs')}),
|
||||
loadConfigFile({projectDir, configFile: path.join(searchDir, 'ava.config.mjs')}),
|
||||
]);
|
||||
|
||||
if (jsonFile !== null) {
|
||||
unsupportedFiles.push(jsonFile);
|
||||
}
|
||||
|
||||
[{config: fileConf, fileForErrorMessage, configFile} = {config: NO_SUCH_FILE, fileForErrorMessage: undefined}, ...conflicting] = results.filter(result => result !== null);
|
||||
|
||||
searchDir = path.dirname(searchDir);
|
||||
|
|
@ -139,5 +160,5 @@ export async function loadConfig({configFile, resolveFrom = process.cwd(), defau
|
|||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
return {config, unsupportedFiles};
|
||||
}
|
||||
|
|
|
|||
19
node_modules/ava/lib/reporters/default.js
generated
vendored
19
node_modules/ava/lib/reporters/default.js
generated
vendored
|
|
@ -220,6 +220,9 @@ export default class Reporter {
|
|||
this.lineNumberErrors.push(event);
|
||||
|
||||
this.write(colors.information(`${figures.warning} Could not parse ${this.relativeFile(event.testFile)} for line number selection`));
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine(colors.errorStack(event.err.stack));
|
||||
this.lineWriter.writeLine();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +234,7 @@ export default class Reporter {
|
|||
}
|
||||
|
||||
case 'hook-finished': {
|
||||
if (true && event.logs.length > 0) {
|
||||
if (event.logs.length > 0) {
|
||||
this.lineWriter.writeLine(` ${this.prefixTitle(event.testFile, event.title)}`);
|
||||
this.writeLogs(event);
|
||||
}
|
||||
|
|
@ -312,7 +315,7 @@ export default class Reporter {
|
|||
this.filesWithoutMatchedLineNumbers.add(event.testFile);
|
||||
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Line numbers for ${this.relativeFile(event.testFile)} did not match any tests`));
|
||||
} else if (true && !this.failFastEnabled && fileStats.remainingTests > 0) {
|
||||
} else if (!this.failFastEnabled && fileStats.remainingTests > 0) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} ${fileStats.remainingTests} ${plur('test', fileStats.remainingTests)} remaining in ${this.relativeFile(event.testFile)}`));
|
||||
}
|
||||
}
|
||||
|
|
@ -515,7 +518,8 @@ export default class Reporter {
|
|||
|
||||
writeFailure(event) {
|
||||
this.lineWriter.writeLine(colors.title(this.prefixTitle(event.testFile, event.title)));
|
||||
if (!this.writeLogs(event, true)) {
|
||||
|
||||
if (!event.logs || event.logs.length === 0) {
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
|
|
@ -570,17 +574,12 @@ export default class Reporter {
|
|||
this.lineWriter.writeLine();
|
||||
|
||||
if (this.failures.length > 0) {
|
||||
const writeTrailingLines = this.internalErrors.length > 0 || this.sharedWorkerErrors.length > 0 || this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
|
||||
|
||||
const lastFailure = this.failures[this.failures.length - 1];
|
||||
for (const event of this.failures) {
|
||||
this.writeFailure(event);
|
||||
if (event !== lastFailure) {
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
} else if (!true && writeTrailingLines) {
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -659,6 +658,10 @@ export default class Reporter {
|
|||
this.lineWriter.writeLine(colors.error(`${this.stats.uncaughtExceptions} uncaught ${plur('exception', this.stats.uncaughtExceptions)}`));
|
||||
}
|
||||
|
||||
if (this.stats.timeouts > 0) {
|
||||
this.lineWriter.writeLine(colors.error(`${this.stats.timeouts} ${plur('test', this.stats.timeouts)} remained pending after a timeout`));
|
||||
}
|
||||
|
||||
if (this.previousFailures > 0) {
|
||||
this.lineWriter.writeLine(colors.error(`${this.previousFailures} previous ${plur('failure', this.previousFailures)} in test files that were not rerun`));
|
||||
}
|
||||
|
|
|
|||
2
node_modules/ava/lib/reporters/tap.js
generated
vendored
2
node_modules/ava/lib/reporters/tap.js
generated
vendored
|
|
@ -4,7 +4,7 @@ import path from 'node:path';
|
|||
import indentString from 'indent-string';
|
||||
import plur from 'plur';
|
||||
import stripAnsi from 'strip-ansi';
|
||||
import supertap from 'supertap';
|
||||
import * as supertap from 'supertap';
|
||||
|
||||
import beautifyStack from './beautify-stack.js';
|
||||
import prefixTitle from './prefix-title.js';
|
||||
|
|
|
|||
5
node_modules/ava/lib/run-status.js
generated
vendored
5
node_modules/ava/lib/run-status.js
generated
vendored
|
|
@ -125,7 +125,10 @@ export default class RunStatus extends Emittery {
|
|||
case 'timeout':
|
||||
event.pendingTests = this.pendingTests;
|
||||
this.pendingTests = new Map();
|
||||
stats.timeouts++;
|
||||
for (const testsInFile of event.pendingTests.values()) {
|
||||
stats.timeouts += testsInFile.size;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'interrupt':
|
||||
event.pendingTests = this.pendingTests;
|
||||
|
|
|
|||
2
node_modules/ava/lib/runner.js
generated
vendored
2
node_modules/ava/lib/runner.js
generated
vendored
|
|
@ -524,7 +524,7 @@ export default class Runner extends Emittery {
|
|||
// If a concurrent test fails, even if `failFast` is enabled it won't
|
||||
// stop other concurrent tests from running.
|
||||
const allOkays = await Promise.all(concurrentTests.map(task => this.runTest(task, contextRef.copy())));
|
||||
return allOkays.every(ok => ok);
|
||||
return allOkays.every(Boolean);
|
||||
});
|
||||
|
||||
const beforeExitHandler = this.beforeExitHandler.bind(this);
|
||||
|
|
|
|||
4
node_modules/ava/lib/snapshot-manager.js
generated
vendored
4
node_modules/ava/lib/snapshot-manager.js
generated
vendored
|
|
@ -391,7 +391,9 @@ class Manager {
|
|||
|
||||
const resolveSourceFile = mem(file => {
|
||||
const sourceMap = findSourceMap(file);
|
||||
if (sourceMap === undefined) {
|
||||
// Prior to Node.js 18.8.0, the value when a source map could not be found was `undefined`.
|
||||
// This changed to `null` in <https://github.com/nodejs/node/pull/43875>. Check both.
|
||||
if (sourceMap === undefined || sourceMap === null) {
|
||||
return file;
|
||||
}
|
||||
|
||||
|
|
|
|||
12
node_modules/ava/lib/test.js
generated
vendored
12
node_modules/ava/lib/test.js
generated
vendored
|
|
@ -24,16 +24,16 @@ const testMap = new WeakMap();
|
|||
class ExecutionContext extends Assertions {
|
||||
constructor(test) {
|
||||
super({
|
||||
pass: () => {
|
||||
pass() {
|
||||
test.countPassedAssertion();
|
||||
},
|
||||
pending: promise => {
|
||||
pending(promise) {
|
||||
test.addPendingAssertion(promise);
|
||||
},
|
||||
fail: error => {
|
||||
fail(error) {
|
||||
test.addFailedAssertion(error);
|
||||
},
|
||||
skip: () => {
|
||||
skip() {
|
||||
test.countPassedAssertion();
|
||||
},
|
||||
compareWithSnapshot: options => test.compareWithSnapshot(options),
|
||||
|
|
@ -109,7 +109,7 @@ class ExecutionContext extends Assertions {
|
|||
logs: [...logs], // Don't allow modification of logs.
|
||||
passed,
|
||||
title: attemptTitle,
|
||||
commit: ({retainLogs = true} = {}) => {
|
||||
commit({retainLogs = true} = {}) {
|
||||
if (committed) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ class ExecutionContext extends Assertions {
|
|||
startingSnapshotCount,
|
||||
});
|
||||
},
|
||||
discard: ({retainLogs = false} = {}) => {
|
||||
discard({retainLogs = false} = {}) {
|
||||
if (committed) {
|
||||
test.saveFirstError(new Error('Can’t discard a result that was previously committed'));
|
||||
return;
|
||||
|
|
|
|||
19
node_modules/ava/lib/worker/line-numbers.js
generated
vendored
19
node_modules/ava/lib/worker/line-numbers.js
generated
vendored
|
|
@ -61,11 +61,18 @@ function findTest(locations, declaration) {
|
|||
const range = (start, end) => Array.from({length: end - start + 1}).fill(start).map((element, index) => element + index);
|
||||
|
||||
const translate = (sourceMap, pos) => {
|
||||
if (sourceMap === undefined) {
|
||||
if (sourceMap === null) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
const entry = sourceMap.findEntry(pos.line - 1, pos.column); // Source maps are 0-based
|
||||
|
||||
// When used with ts-node/register, we've seen entries without original values. Return the
|
||||
// original position.
|
||||
if (entry.originalLine === undefined || entry.originalColumn === undefined) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
return {
|
||||
line: entry.originalLine + 1, // Readjust for Acorn.
|
||||
column: entry.originalColumn,
|
||||
|
|
@ -81,7 +88,7 @@ export default function lineNumberSelection({file, lineNumbers = []}) {
|
|||
|
||||
let locations = parse(file);
|
||||
let lookedForSourceMap = false;
|
||||
let sourceMap;
|
||||
let sourceMap = null;
|
||||
|
||||
return () => {
|
||||
if (!lookedForSourceMap) {
|
||||
|
|
@ -91,7 +98,13 @@ export default function lineNumberSelection({file, lineNumbers = []}) {
|
|||
// Source maps are not available before then.
|
||||
sourceMap = findSourceMap(file);
|
||||
|
||||
if (sourceMap !== undefined) {
|
||||
if (sourceMap === undefined) {
|
||||
// Prior to Node.js 18.8.0, the value when a source map could not be found was `undefined`.
|
||||
// This changed to `null` in <https://github.com/nodejs/node/pull/43875>.
|
||||
sourceMap = null;
|
||||
}
|
||||
|
||||
if (sourceMap !== null) {
|
||||
locations = locations.map(({start, end}) => ({
|
||||
start: translate(sourceMap, start),
|
||||
end: translate(sourceMap, end),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue