From 7166608a9619904827dddd1209a42fd9c5147c56 Mon Sep 17 00:00:00 2001 From: Adrian Dymorz Date: Fri, 27 Mar 2020 14:50:44 +0100 Subject: [PATCH 1/2] Add option outputfile Allow to save a copy of stdout to a file --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index e47f0c7..27df03f 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ const through = require('through2'); const dargs = require('dargs'); const resolveCwd = require('resolve-cwd'); const execa = require('execa'); +const fs = require('fs'); const BINARY = require.resolve('ava/cli.js'); @@ -50,6 +51,11 @@ module.exports = options => { subprocess.stderr.pipe(process.stderr); } + if (options.outputfile) { + let filestream = fs.createWriteStream(options.outputfile); + subprocess.stdout.pipe(filestream); + } + try { await subprocess; callback(); From 3eec8556f527531049fddbb18c9d76cd41f2fc9f Mon Sep 17 00:00:00 2001 From: Adrian Dymorz Date: Thu, 5 Aug 2021 14:11:26 +0200 Subject: [PATCH 2/2] Changes after review --- index.js | 6 +++--- readme.md | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 27df03f..f576ce1 100644 --- a/index.js +++ b/index.js @@ -51,9 +51,9 @@ module.exports = options => { subprocess.stderr.pipe(process.stderr); } - if (options.outputfile) { - let filestream = fs.createWriteStream(options.outputfile); - subprocess.stdout.pipe(filestream); + if (options.outputFile) { + const fileStream = fs.createWriteStream(options.outputFile); + subprocess.stdout.pipe(fileStream); } try { diff --git a/readme.md b/readme.md index 9ea71a2..7563dbf 100644 --- a/readme.md +++ b/readme.md @@ -45,3 +45,10 @@ Type: `boolean`
Default: `false` Run AVA with [`nyc`](https://github.com/istanbuljs/nyc). You must have `nyc` as a devDependency. `nyc` [options](https://github.com/istanbuljs/nyc#configuring-nyc) can be defined in package.json. + +#### outputFile + +Type: `string`
+Default: `undefined` + +Store a copy of the stdout of AVA as a file. Example: `tests/output/tapOutput.txt`