-
-
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.
Merge pull request #17 from feross/remove-standard
BREAKING: Remove built-in copy of `standard`
- Loading branch information
Showing
5 changed files
with
34 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
language: node_js | ||
sudo: true | ||
node_js: | ||
- '0.10' | ||
- '0.12' | ||
- 'iojs' | ||
- 'node' |
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,29 @@ | ||
#!/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.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 | ||
} |
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