Skip to content

Commit

Permalink
[Fix] in engines that lack dynamic import, have some output
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Sep 14, 2024
1 parent 627d1e7 commit 2d5c8dc
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions bin/tape
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,26 @@ var hasImport = require('has-dynamic-import');
var tape = require('../');

function importFiles(hasSupport) {
if (!hasSupport) {
return files.forEach(function (x) { require(x); });
}

var importOrRequire = require('./import-or-require');

tape.wait();

var filesPromise = files.reduce(function (promise, file) {
return promise ? promise.then(function () {
return importOrRequire(file);
}) : importOrRequire(file);
}, null);
var filesPromise;
if (hasSupport) {
var importOrRequire = require('./import-or-require');

filesPromise = files.reduce(function (promise, file) {
return promise ? promise.then(function () {
return importOrRequire(file);
}) : importOrRequire(file);
}, null);
} else {
files.forEach(function (x) { require(x); });
}

return filesPromise ? filesPromise.then(function () { tape.run(); }) : tape.run();
if (filesPromise) {
filesPromise.then(function () { tape.run(); });
} else {
tape.run();
}
}

hasImport().then(function (hasSupport) {
Expand Down

0 comments on commit 2d5c8dc

Please sign in to comment.