diff --git a/.travis.yml b/.travis.yml index b4bcd99..0be402b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,3 @@ language: node_js -sudo: true node_js: -- '0.10' -- '0.12' -- 'iojs' +- 'node' diff --git a/README.md b/README.md index 70a485b..de87dac 100644 --- a/README.md +++ b/README.md @@ -33,17 +33,18 @@ Pipe "compact" text into the `snazzy` command to get back pretty results: $ standard --verbose | snazzy ``` -Or, just run `snazzy` directly and it will run `standard` and give you pretty results: +## note about version 7.0.0 -```bash -$ snazzy -``` +`standard` is no longer bundled with snazzy. You must install `standard` manually +alongside `snazzy`. -`snazzy` supports all command line flags that `standard` supports: +Run `npm install standard --save-dev` to get a copy of `standard`, then run +`standard | snazzy` where you previously used to ran `snazzy`. -```bash -$ snazzy --format --verbose test1.js test2.js -``` +This method requires more steps but it's better since the user controls the exact +version of `standard` that is used. And for users who were piping into `snazzy` all +along, this means a quicker install since an extra copy of `standard` will not get +installed. ## license diff --git a/bin/cmd.js b/bin/cmd.js index ea98fe2..f07757b 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -1,12 +1,7 @@ #!/usr/bin/env node var CompactToStylishStream = require('../') -var cp = require('child_process') var minimist = require('minimist') -var path = require('path') - -var STANDARD_CMD = path.join(require.resolve('standard'), '../../.bin/standard') -if (process.platform === 'win32') STANDARD_CMD += '.cmd' var argv = minimist(process.argv.slice(2), { boolean: [ @@ -14,33 +9,21 @@ var argv = minimist(process.argv.slice(2), { ] }) -var snazzy = new CompactToStylishStream() - -// Set the process exit code based on whether snazzy found errors. -process.on('exit', function (code) { - if (code === 0 && snazzy.exitCode !== 0) { - process.exit(snazzy.exitCode) - } -}) -process.stdout.on('error', function () {}) - if (!process.stdin.isTTY || argv._[0] === '-' || argv.stdin) { - process.stdin.pipe(snazzy).pipe(process.stdout) -} else { - var args = process.argv.slice(2) - var standard = cp.spawn(STANDARD_CMD, args) - standard.stderr.pipe(process.stderr) - standard.stdout.pipe(snazzy).pipe(process.stdout) + var snazzy = new CompactToStylishStream() - // This only runs if snazzy finds no errors AND `standard` exited with a - // non-zero code. That means something weird happened, so set exit code to - // non-zero. - var standardCode - standard.on('exit', function (code) { standardCode = code }) + // Set the process exit code based on whether snazzy found errors process.on('exit', function (code) { - if (code === 0 && standardCode !== 0) { - console.error('Unexpected exit from the `standard` command') - process.exit(standardCode) + if (code === 0 && snazzy.exitCode !== 0) { + process.exitCode = snazzy.exitCode } }) + + process.stdin.pipe(snazzy).pipe(process.stdout) +} else { + console.error(` +snazzy: 'standard' is no longer bundled with 'snazzy'. Install standard +snazzy: ('npm install standard') then run 'standard | snazzy' instead. + `) + process.exitCode = 1 } diff --git a/index.js b/index.js index 1c52c15..2f39ee6 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,7 @@ function CompactToStylishStream (opts) { } stream.Transform.call(this, opts) + this.exitCode = 0 this._buffer = [] } diff --git a/package.json b/package.json index ea059c3..37e364c 100644 --- a/package.json +++ b/package.json @@ -18,22 +18,24 @@ "inherits": "^2.0.1", "minimist": "^1.1.1", "readable-stream": "^2.0.6", - "standard": "*", "standard-json": "^1.0.0", "text-table": "^0.2.0" }, + "devDependencies": { + "standard": "*" + }, "homepage": "https://github.com/feross/snazzy", "keywords": [ - "stylish standard", - "stylish for standard", - "stylish formatter", + "pretty", + "pretty output", "snazzy standard", + "standard", + "standard pretty", "stylish", + "stylish for standard", + "stylish formatter", "stylish reporter", - "standard", - "pretty output", - "pretty", - "standard pretty" + "stylish standard" ], "license": "MIT", "main": "index.js", @@ -42,6 +44,6 @@ "url": "git://github.com/feross/snazzy.git" }, "scripts": { - "test": "./bin/cmd.js --verbose" + "test": "standard --verbose | ./bin/cmd.js" } }