Skip to content
This repository was archived by the owner on Aug 8, 2020. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,26 @@ module.exports = options => {
args.unshift(nycBin);
}

const subprocess = execa(process.execPath, args, {buffer: false});
const processPromise = execa(process.execPath, args, {buffer: false});

const closePromise = new Promise((resolve, reject) => {
processPromise.on('close', exitCode =>
exitCode === 0 ?
resolve() :
reject());
});

if (!options.silent) {
subprocess.stdout.pipe(process.stdout);
subprocess.stderr.pipe(process.stderr);
processPromise.stdout.pipe(process.stdout);
processPromise.stderr.pipe(process.stderr);
}

try {
await subprocess;
await Promise.race([
processPromise,
closePromise
]);

callback();
} catch (_) {
callback(new PluginError('gulp-ava', 'One or more tests failed'));
Expand Down