-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING: Remove built-in copy of
standard
`standard` is no longer bundled with snazzy. You must install `standard` manually alongside `snazzy`. Run `npm install standard --save-dev` to get a copy of `standard`, then run `standard | snazzy` where you previously used to ran `snazzy`. Though this takes more steps, it's better because it allows the user to control the exact version of `standard` that gets 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.
- Loading branch information
Showing
3 changed files
with
33 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,30 @@ | ||
#!/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: [ | ||
'stdin' | ||
] | ||
}) | ||
|
||
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.exit(snazzy.exitCode) | ||
} | ||
}) | ||
|
||
process.stdout.on('error', function () {}) | ||
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 | ||
} |
This file contains 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