Skip to content

Commit

Permalink
Anticipate asynchronous loads
Browse files Browse the repository at this point in the history
  • Loading branch information
novemberborn committed Jan 5, 2020
1 parent e919b40 commit 8bdcf8b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/worker/subprocess.js
Expand Up @@ -6,7 +6,7 @@ require('./ensure-forked'); // eslint-disable-line import/no-unassigned-import
const ipc = require('./ipc');

ipc.send({type: 'ready-for-options'});
ipc.options.then(options => {
ipc.options.then(async options => {
require('./options').set(options);
require('../chalk').set(options.chalkOptions);

Expand Down Expand Up @@ -126,7 +126,7 @@ ipc.options.then(options => {
}

let requireFn = require;
const load = ref => {
const load = async ref => {
for (const extension of extensionsToLoadAsModules) {
if (ref.endsWith(`.${extension}`)) {
ipc.send({type: 'internal-error', err: serializeError('Internal runner error', false, new Error('AVA cannot yet load ESM files.'))});
Expand All @@ -143,8 +143,8 @@ ipc.options.then(options => {
};

try {
for (const ref of (options.require || [])) {
const mod = load(ref);
for await (const ref of (options.require || [])) {
const mod = await load(ref);

try {
if (Reflect.has(mod, Symbol.for('esm:package'))) {
Expand All @@ -164,7 +164,7 @@ ipc.options.then(options => {
}
}

load(testPath);
await load(testPath);

if (accessedRunner) {
// Unreference the IPC channel if the test file required AVA. This stops it
Expand Down

0 comments on commit 8bdcf8b

Please sign in to comment.