Skip to content

Commit

Permalink
feat: add what-broke CLI command
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Feb 10, 2021
1 parent a20646e commit 86a521c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ npm i -g npm-fetch-changelog

```
npm-fetch-changelog <package name>[@<range>]
what-broke <package name>[@<range>]
```

Prints changelog entries fetched from GitHub for each
version released on npm in the given range.

`what-broke` is just a shortcut for `npm-fetch-changelog --no-minor`.

## Options:

### `-r`, `--range`
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@
"yargs": "^13.2.2"
},
"bin": {
"npm-fetch-changelog": "./cli.js"
"npm-fetch-changelog": "./cli/npm-fetch-changelog.js",
"what-broke": "./cli/what-broke.js"
},
"engines": {
"node": ">=12"
Expand Down
4 changes: 2 additions & 2 deletions src/cli.js → src/cli/npm-fetch-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import chalk from 'chalk'
import yargs from 'yargs'
import path from 'path'
import { fetchChangelog } from './index'
import { type Release } from './parseChangelog'
import { fetchChangelog } from '../index'
import { type Release } from '../parseChangelog'

/* eslint-env node */
const { argv } = yargs
Expand Down
26 changes: 26 additions & 0 deletions src/cli/what-broke.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

// @flow

import { spawn } from 'child_process'

const child = spawn(
process.execPath,
[
require.resolve('./npm-fetch-changelog.js'),
...process.argv.slice(2),
'--no-minor',
],
{
stdio: 'inherit',
}
)
child.on('error', (error: Error) => {
// eslint-disable-next-line no-console
console.error(error.stack)
process.exit(1)
})
child.on('close', (code?: number, signal?: string) => {
if (code != null) process.exit(code)
process.exit(signal ? 1 : 0)
})
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5866,6 +5866,11 @@ nerf-dart@^1.0.0:
resolved "https://registry.npmjs.org/nerf-dart/-/nerf-dart-1.0.0.tgz#e6dab7febf5ad816ea81cf5c629c5a0ebde72c1a"
integrity sha1-5tq3/r9a2Bbqgc9cYpxaDr3nLBo=

nice-try@^1.0.4:
version "1.0.5"
resolved "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==

node-emoji@^1.10.0:
version "1.10.0"
resolved "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz#8886abd25d9c7bb61802a658523d1f8d2a89b2da"
Expand Down Expand Up @@ -6693,7 +6698,7 @@ path-is-inside@^1.0.1, path-is-inside@^1.0.2, path-is-inside@~1.0.2:
resolved "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=

path-key@^2.0.0:
path-key@^2.0.0, path-key@^2.0.1:
version "2.0.1"
resolved "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=
Expand Down

0 comments on commit 86a521c

Please sign in to comment.