mirror of
https://github.com/github/codeql-action.git
synced 2025-12-30 03:00:13 +08:00
19 lines
600 B
JavaScript
19 lines
600 B
JavaScript
'use strict';
|
||
const path = require('path');
|
||
const chalk = require('chalk'); // Use default Chalk instance.
|
||
|
||
// Check if the test is being run without AVA cli
|
||
const isForked = typeof process.send === 'function';
|
||
if (!isForked) {
|
||
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 ${chalk.grey.dim('$')} ${chalk.cyan('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');
|
||
}
|
||
}
|