nathanboktae / mocha-phantomjs

:coffee: :ghost: Run client-side mocha tests in the command line through phantomjs
MIT License
954 stars 112 forks source link

Add support for transforming stdout/stderr #219

Closed jdlehman closed 9 years ago

jdlehman commented 9 years ago

This allows users to transform stdout/stderr streams, which enables things like source map support. These transforms work like hooks, except they are expected to be valid arguments to pipe. When these arguments are not provided, data passes through to stdout/stderr unchanged.

Source map support using sourcemap-transformer:

// ./myTransformer.js
var createSourceMapTransformer = require('sourcemap-transformer').createSourceMapTransformer;
var sourceMapTransformer = createSourceMapTransformer();

module.exports = sourceMapTransformer;
mocha-phantomjs -R dot --stdoutTransform ./myTransformer.js
nathanboktae commented 9 years ago

Do you know the pipe operator was invented in 1973 ?

mocha-phantomjs -R dot | node ./myTransformer.js
metaskills commented 9 years ago

@nathanboktae Great technical point. But please be more empathetic with the responses. Even if Jonathan was not a co-worker of mine, we should be nice. Sometimes people hit things from the wrong angle and that is OK.

A friendly feedback can go a long way to establishing good open source relationships. I've made a few mistakes like this before, but please try to keep this project and our faces + to those that want to help. Thanks.

nathanboktae commented 9 years ago

True Ken, I should be. PRs are like publicity, it's always good that people want to contribute.

@jdlehman Apologies for the snappiness. Keeping to the spirit of the single responsibility principle, there is no reason to have this concern in when shells, and really anything that executes a process can pipe streams in just fine.

jdlehman commented 9 years ago

@nathanboktae No problem, maintaining OSS isn't easy. I definitely agree with you that piping with the shell is the better way to go. I got so caught up in other details with what I was trying to do that the obvious solution escaped me. Thanks for pointing that out.