Skip to content
This repository has been archived by the owner on Feb 22, 2021. It is now read-only.

Save report to a file #29

Merged
merged 2 commits into from
Sep 15, 2015
Merged

Save report to a file #29

merged 2 commits into from
Sep 15, 2015

Conversation

borisdiakur
Copy link
Contributor

This pull request resolves #17 by hooking into process.stdout and writing the reporter output to a file. To do that the user can set one additional option outputPath. The path includes filename and extention (two options, reportFormat and reportFile, seemed redundant).
I also did some cleanup, hope you don't mind (see commits).

@stefanjudis
Copy link
Owner

@borisdiakur

Oh wow - that's what I call a PR. Nice one!

Will have a look right now. :) Thanks.

},

reportToFile: function(test) {
fs.mkdir('tmp', function () {
Copy link
Owner

Choose a reason for hiding this comment

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

You're creating a directory here, which won't be removed after test run.
We may want to remove it afterwards?

Choose a reason for hiding this comment

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

Right now fs.rmdir wouldn't run if any of the assertions failed. I'd suggest placing it in /tmp or the os tmp dir :) https://github.com/raszi/node-tmp

Copy link
Owner

Choose a reason for hiding this comment

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

👍

@stefanjudis
Copy link
Owner

@borisdiakur

Thanks for taking the time. A had a few notes - maybe we wanna discuss these.

The actual implementation is a bit hard to understand at the beginning - but I thought about it and probably wouldn't come to a nice solution. So this might be fine. :)

Maybe we can add some comments or something? I'm not sure about it. :bowtie:

Overall really good PR. Thanks for that.

Maybe @paazmaya can also have a look. :)

And yeah 👍 👍 👍 for some clean up!!!

@borisdiakur
Copy link
Contributor Author

You're welcome. Actually I'd find it cleaner if the jsinspect module would offer the write to file part. That way we wouldn't have to use such a hack. Maybe we should send another PR to the other repo...

@stefanjudis
Copy link
Owner

Actually I'd find it cleaner if the jsinspect module would offer the write to file part.

Agree on that - maybe we wanna keep this one open, until @danielstjules decides that he would take it?

@danielstjules
Copy link

If I was using npm scripts or make, I'd just pipe the output: jsinspect . > yourfile Is there a clean alternative to this with grunt?

I guess one improvement would be to update the reporters to accept the stream to write to, rather than assume process.stdout.

@stefanjudis
Copy link
Owner

If I was using npm scripts or make, I'd just pipe the output: jsinspect . > yourfile Is there a clean alternative to this with grunt?

Hah, was expecting this reply. ;)

I guess one improvement would be to update the reporters to accept the stream to write to, rather than assume process.stoudout.

Might work yes.

What do you think about providing the reporter result with the end event?

https://github.com/stefanjudis/grunt-jsinspect/blob/master/tasks/jsinspect.js#L64-L66

E.g.

    inspector.on('end', function(result) {
      // do something with the result here

      done(taskSucceeded);
    });

@borisdiakur
Copy link
Contributor Author

@danielstjules See danielstjules/jsinspect#24 - I'm about to fork your repo. Will create a PR.

@borisdiakur
Copy link
Contributor Author

PR created: danielstjules/jsinspect#25
heading out for 🍕

@danielstjules
Copy link

I like the idea of accepting a writable stream. Makes integration tests super easy as well, since capturing stdout from mocha is a PITA :)

@borisdiakur
Copy link
Contributor Author

PR danielstjules/jsinspect#25 has been accepted. Thanks @danielstjules!
Now we have to wait until the next release of jsinspect in order to rework and complete this PR.

@stefanjudis
Copy link
Owner

Good job @borisdiakur! 🎉

@danielstjules
Copy link

Just pushed a new release :) Please note that I renamed the option. Thanks for your patience, and all your help!

@stefanjudis
Copy link
Owner

👍 🎉

Nice example of open source collaboration! Love it!

@borisdiakur
Copy link
Contributor Author

That was fast! Thanks again @danielstjules! Ok, I guess it's my turn now. Hang tight!

This commit includes the actual implementation...
- added reportToFile test
- updated readme with new option outputPath
- passing a writable stream to jsinspect reporters
- bumped jsinspect version to 0.7.0

...and some cleanup
- adjusted eslint rules to chosen code style
- removed unused files
- simple license entry (so that npm doesn't complain anymore)
- removed unnecessary grunt-contrib-clean dep and call
@borisdiakur
Copy link
Contributor Author

The PR should be 👌 now. @stefanjudis: Your turn.

@borisdiakur
Copy link
Contributor Author

tmp is nice!

@paazmaya
Copy link
Collaborator

Sweet 🍠 !

@stefanjudis
Copy link
Owner

okay looks good to me. :)

stefanjudis added a commit that referenced this pull request Sep 15, 2015
@stefanjudis stefanjudis merged commit eb2c264 into stefanjudis:master Sep 15, 2015
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.

Save report to a file, text and JSON formats
4 participants