Skip to content

Commit b460ea4

Browse files
committed
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.
1 parent f2172ff commit b460ea4

File tree

3 files changed

+33
-46
lines changed

3 files changed

+33
-46
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@ Pipe "compact" text into the `snazzy` command to get back pretty results:
3333
$ standard --verbose | snazzy
3434
```
3535

36-
Or, just run `snazzy` directly and it will run `standard` and give you pretty results:
36+
## note about version 7.0.0
3737

38-
```bash
39-
$ snazzy
40-
```
38+
`standard` is no longer bundled with snazzy. You must install `standard` manually
39+
alongside `snazzy`.
4140

42-
`snazzy` supports all command line flags that `standard` supports:
41+
Run `npm install standard --save-dev` to get a copy of `standard`, then run
42+
`standard | snazzy` where you previously used to ran `snazzy`.
4343

44-
```bash
45-
$ snazzy --format --verbose test1.js test2.js
46-
```
44+
This method requires more steps but it's better since the user controls the exact
45+
version of `standard` that is used. And for users who were piping into `snazzy` all
46+
along, this means a quicker install since an extra copy of `standard` will not get
47+
installed.
4748

4849
## license
4950

bin/cmd.js

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,30 @@
11
#!/usr/bin/env node
22

33
var CompactToStylishStream = require('../')
4-
var cp = require('child_process')
54
var minimist = require('minimist')
6-
var path = require('path')
7-
8-
var STANDARD_CMD = path.join(require.resolve('standard'), '../../.bin/standard')
9-
if (process.platform === 'win32') STANDARD_CMD += '.cmd'
105

116
var argv = minimist(process.argv.slice(2), {
127
boolean: [
138
'stdin'
149
]
1510
})
1611

17-
var snazzy = new CompactToStylishStream()
18-
19-
// Set the process exit code based on whether snazzy found errors.
20-
process.on('exit', function (code) {
21-
if (code === 0 && snazzy.exitCode !== 0) {
22-
process.exit(snazzy.exitCode)
23-
}
24-
})
25-
process.stdout.on('error', function () {})
26-
2712
if (!process.stdin.isTTY || argv._[0] === '-' || argv.stdin) {
28-
process.stdin.pipe(snazzy).pipe(process.stdout)
29-
} else {
30-
var args = process.argv.slice(2)
31-
var standard = cp.spawn(STANDARD_CMD, args)
32-
standard.stderr.pipe(process.stderr)
33-
standard.stdout.pipe(snazzy).pipe(process.stdout)
13+
var snazzy = new CompactToStylishStream()
3414

35-
// This only runs if snazzy finds no errors AND `standard` exited with a
36-
// non-zero code. That means something weird happened, so set exit code to
37-
// non-zero.
38-
var standardCode
39-
standard.on('exit', function (code) { standardCode = code })
15+
// Set the process exit code based on whether snazzy found errors.
4016
process.on('exit', function (code) {
41-
if (code === 0 && standardCode !== 0) {
42-
console.error('Unexpected exit from the `standard` command')
43-
process.exit(standardCode)
17+
if (code === 0 && snazzy.exitCode !== 0) {
18+
process.exit(snazzy.exitCode)
4419
}
4520
})
21+
22+
process.stdout.on('error', function () {})
23+
process.stdin.pipe(snazzy).pipe(process.stdout)
24+
} else {
25+
console.error(`
26+
snazzy: 'standard' is no longer bundled with 'snazzy'. Install standard
27+
snazzy: ('npm install standard') then run 'standard | snazzy' instead.
28+
`)
29+
process.exitCode = 1
4630
}

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,24 @@
1818
"inherits": "^2.0.1",
1919
"minimist": "^1.1.1",
2020
"readable-stream": "^2.0.6",
21-
"standard": "*",
2221
"standard-json": "^1.0.0",
2322
"text-table": "^0.2.0"
2423
},
24+
"devDependencies": {
25+
"standard": "*"
26+
},
2527
"homepage": "https://github.com/feross/snazzy",
2628
"keywords": [
27-
"stylish standard",
28-
"stylish for standard",
29-
"stylish formatter",
29+
"pretty",
30+
"pretty output",
3031
"snazzy standard",
32+
"standard",
33+
"standard pretty",
3134
"stylish",
35+
"stylish for standard",
36+
"stylish formatter",
3237
"stylish reporter",
33-
"standard",
34-
"pretty output",
35-
"pretty",
36-
"standard pretty"
38+
"stylish standard"
3739
],
3840
"license": "MIT",
3941
"main": "index.js",
@@ -42,6 +44,6 @@
4244
"url": "git://github.com/feross/snazzy.git"
4345
},
4446
"scripts": {
45-
"test": "./bin/cmd.js --verbose"
47+
"test": "standard --verbose | ./bin/cmd.js"
4648
}
4749
}

0 commit comments

Comments
 (0)