Skip to content
This repository has been archived by the owner on Aug 8, 2020. It is now read-only.

Add outputFile option #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

adymorz
Copy link

@adymorz adymorz commented Mar 27, 2020

Allow to save a copy of stdout to a file

Allow to save a copy of stdout to a file
@sindresorhus
Copy link
Member

Why? What's the use-case?

@adymorz
Copy link
Author

adymorz commented Mar 27, 2020

In my gulp file I have got:

function runRegulatoryTests() {
	return gulp.src([
		"tests/regulatory/commentPeriods.js",
	]).pipe(ava({
		tap: true,
		failFast: argv["ava-failfast"],
		concurrency: parseInt(argv["ava-concurrency"]),
		outputfile: 'tests/output/tapOutput.txt',
		"_":[
			"--",
			"--browser",
			argv["ava-browser"],
			"--headless",
			argv["ava-headless"],
		]
	}));
}

The new option outputfile allows me to store a copy of the stdout (and not stderr) of ava (and nothing more) as a file. This allows me to further process the output (we actually generate a graphical test report containing test descriptions and screenshots).

@sindresorhus
Copy link
Member

sindresorhus commented Mar 27, 2020

It seems like this would be better as an option for AVA itself, not just this Gulp plugin.

Can you open an issue on https://github.com/avajs/ava ?

@adymorz
Copy link
Author

adymorz commented Mar 27, 2020

I just created a ticket in AVA to get a confirmation for the idea: avajs/ava#2431

@adymorz
Copy link
Author

adymorz commented Mar 27, 2020

After the answer of @novemberborn in the AVA ticket it is a gulp-ava topic again, I guess?

@adymorz
Copy link
Author

adymorz commented Mar 27, 2020

And alternative approach would be to add an option outputstreams which would allow to pass in one ore more outputstreams. This would allow to use different TAP reportes simultaneously, e.g. faucet for the output in the console (stdout) and ava-tap-json which would get piped to a file write stream.

When streaming the output to the console one should activate the option silent to prevent mixed output.

Both the original approach using outputfile and the newly proposed using outputstreams would extend the current functionality without having a risk to break something.

I personally like the new idea better even though it is a bit harder to understand, because it allows more flexibility. What do you think, @sindresorhus?

@novemberborn
Copy link
Member

FWIW I have no interest in maintaining gulp-ava (sorry @adymorz). I'm happy to ship whatever here.

index.js Outdated
@@ -50,6 +51,11 @@ module.exports = options => {
subprocess.stderr.pipe(process.stderr);
}

if (options.outputfile) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (options.outputfile) {
if (options.outputFile) {

And the option needs to be documented in the readme.

index.js Outdated
@@ -50,6 +51,11 @@ module.exports = options => {
subprocess.stderr.pipe(process.stderr);
}

if (options.outputfile) {
let filestream = fs.createWriteStream(options.outputfile);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let filestream = fs.createWriteStream(options.outputfile);
const fileStream = fs.createWriteStream(options.outputfile);

@sindresorhus sindresorhus changed the title Add option outputfile Add outputFile option May 10, 2020
@sindresorhus
Copy link
Member

Alright. Let's add it here then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants