|
1 | 1 | 'use strict';
|
2 | 2 | const {pathToFileURL} = require('url');
|
3 |
| -const path = require('path'); |
4 | 3 | const currentlyUnhandled = require('currently-unhandled')();
|
5 |
| -const {isRunningInThread, isRunningInChildProcess} = require('./utils'); |
| 4 | +const {isRunningInThread, isRunningInChildProcess} = require('./utils.cjs'); |
6 | 5 |
|
7 |
| -// Check if the test is being run without AVA cli |
8 |
| -if (!isRunningInChildProcess && !isRunningInThread) { |
9 |
| - const chalk = require('chalk'); // Use default Chalk instance. |
10 |
| - if (process.argv[1]) { |
11 |
| - const fp = path.relative('.', process.argv[1]); |
12 |
| - |
13 |
| - console.log(); |
14 |
| - console.error(`Test files must be run with the AVA CLI:\n\n ${chalk.grey.dim('$')} ${chalk.cyan('ava ' + fp)}\n`); |
15 |
| - |
16 |
| - process.exit(1); |
17 |
| - } else { |
18 |
| - throw new Error('The ’ava’ module can only be imported in test files'); |
19 |
| - } |
20 |
| -} |
21 |
| - |
22 |
| -const channel = require('./channel'); |
| 6 | +const channel = require('./channel.cjs'); |
23 | 7 |
|
24 | 8 | const run = async options => {
|
25 |
| - require('./options').set(options); |
| 9 | + require('./options.cjs').set(options); |
26 | 10 | require('../chalk').set(options.chalkOptions);
|
27 | 11 |
|
28 | 12 | if (options.chalkOptions.level > 0) {
|
29 | 13 | const {stdout, stderr} = process;
|
30 | 14 | global.console = Object.assign(global.console, new console.Console({stdout, stderr, colorMode: true}));
|
31 | 15 | }
|
32 | 16 |
|
33 |
| - const nowAndTimers = require('../now-and-timers'); |
| 17 | + const nowAndTimers = require('../now-and-timers.cjs'); |
34 | 18 | const providerManager = require('../provider-manager');
|
35 | 19 | const Runner = require('../runner');
|
36 | 20 | const serializeError = require('../serialize-error');
|
37 | 21 | const dependencyTracking = require('./dependency-tracker');
|
38 | 22 | const lineNumberSelection = require('./line-numbers');
|
39 | 23 |
|
40 |
| - const sharedWorkerTeardowns = []; |
| 24 | + const {sharedWorkerTeardowns} = require('./state.cjs'); |
41 | 25 |
|
42 | 26 | async function exit(code) {
|
43 | 27 | if (!process.exitCode) {
|
@@ -140,19 +124,6 @@ const run = async options => {
|
140 | 124 | return runner;
|
141 | 125 | };
|
142 | 126 |
|
143 |
| - exports.registerSharedWorker = (filename, initialData, teardown) => { |
144 |
| - const {channel: sharedWorkerChannel, forceUnref, ready} = channel.registerSharedWorker(filename, initialData); |
145 |
| - runner.waitForReady.push(ready); |
146 |
| - sharedWorkerTeardowns.push(async () => { |
147 |
| - try { |
148 |
| - await teardown(); |
149 |
| - } finally { |
150 |
| - forceUnref(); |
151 |
| - } |
152 |
| - }); |
153 |
| - return sharedWorkerChannel; |
154 |
| - }; |
155 |
| - |
156 | 127 | // Store value to prevent required modules from modifying it.
|
157 | 128 | const testPath = options.file;
|
158 | 129 |
|
|
0 commit comments