Skip to content

Commit 8412038

Browse files
committed
feat: handle ENOTFOUND and ask users to report all other errors; closes #78
This PR will ask users to report unhandled rejections or uncaught exceptions to the project issue tracker. - added a test to check this is working - added dev dep [execa](https://npm.im/execa) for said test - added [buggin](https://npm.im/buggin) unexpected error output
1 parent f708d61 commit 8412038

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

bin/good-first-issue.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
require('buggin')(module)
34
const cli = require('commander')
45
const chalk = require('chalk')
56
const opn = require('open')
@@ -49,8 +50,16 @@ cli
4950
process.exitCode = 0
5051
}
5152
} catch (err) {
52-
console.error(err)
53-
process.exitCode = 1
53+
if (err && typeof err === 'object') {
54+
if (/ENOTFOUND/.test(err.message)) {
55+
process.exitCode = 1
56+
return console.error(`${chalk.red('Problem!')} Unable to find api.github.com.\nPlease check your network connection and/or DNS configuration.`)
57+
}
58+
// add more cases here as they come up, and present user-friendly messages
59+
}
60+
61+
// let buggin handle it if it's anything else
62+
throw err
5463
}
5564
})
5665
.parse(process.argv)

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
],
2121
"repository": {
2222
"type": "git",
23-
"url": "https://github.com/bnb/good-first-issue.git"
23+
"url": "https://github.com/cutenode/good-first-issue.git"
2424
},
25-
"homepage": "https://github.com/bnb/good-first-issue",
25+
"homepage": "https://github.com/cutenode/good-first-issue",
2626
"keywords": [
2727
"cli",
2828
"node-cli",
@@ -43,21 +43,23 @@
4343
"node": ">=8.0.0"
4444
},
4545
"bugs": {
46-
"url": "https://github.com/bnb/good-first-issue/issues",
46+
"url": "https://github.com/cutenode/good-first-issue/issues",
4747
"email": "[email protected]"
4848
},
4949
"contributors": [
5050
"Dhruv Jain <[email protected]> (https://maddhruv.github.io)"
5151
],
5252
"dependencies": {
5353
"boxen": "^3.0.0",
54+
"buggin": "^0.1.5",
5455
"chalk": "^2.4.1",
5556
"commander": "^2.19.0",
5657
"inquirer": "^6.2.0",
5758
"libgfi": "^1.0.2",
5859
"open": "^6.4.0"
5960
},
6061
"devDependencies": {
62+
"execa": "^3.3.0",
6163
"jest": "^23.6.0",
6264
"strip-ansi": "^5.0.0",
6365
"standard": "^14.0.0"

tests/cli.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const execa = require('execa')
2+
3+
const BIN_PATH = require.resolve('../bin/good-first-issue.js')
4+
5+
test('should display link to report bug if project not found', async () => {
6+
return expect(
7+
execa(process.execPath, [
8+
BIN_PATH,
9+
'marvin-k-mooney/would-you-please-go-now'
10+
])
11+
)
12+
.resolves.toMatchObject({stderr: /The following unhandled rejection is likely a bug in good-first-issue/})
13+
});

0 commit comments

Comments
 (0)