Files
codeql-action/node_modules/ava/lib/worker/guard-environment.cjs
2023-01-18 21:00:07 +00:00

20 lines
607 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict';
const path = require('node:path');
const process = require('node:process');
const {isRunningInThread, isRunningInChildProcess} = require('./utils.cjs');
// Check if the test is being run without AVA cli
if (!isRunningInChildProcess && !isRunningInThread) {
if (process.argv[1]) {
const fp = path.relative('.', process.argv[1]);
console.log();
console.error(`Test files must be run with the AVA CLI:\n\n $ ava ${fp}\n`);
process.exit(1); // eslint-disable-line unicorn/no-process-exit
} else {
throw new Error('The ava module can only be imported in test files');
}
}