Last active
August 29, 2015 14:23
-
-
Save jonknapp/3ab1123c0b368446a850 to your computer and use it in GitHub Desktop.
Run tap/tape tests from within Grunt and throw errors appropriately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| grunt.registerMultiTask('tape', 'Run tap/tape tests from within grunt.', function () { | |
| var done = this.async(); | |
| var faucet = require('faucet'); | |
| var tapParser = require('tap-parser'); | |
| var parser = tapParser(function (results) { | |
| if (results.fail > 0) { | |
| grunt.fail.warn(results.fail + ' test(s) have failed'); | |
| } else { | |
| done(); | |
| } | |
| }); | |
| var runner = grunt.util.spawn({ | |
| args: this.filesSrc, | |
| cmd: require.resolve('tape/bin/tape') | |
| }, function() {}); | |
| runner.stderr.pipe(process.stderr, { end: false }); | |
| runner.stdout.pipe(parser); | |
| runner.stdout.pipe(faucet()).pipe(process.stdout); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment