Skip to content

Commit

Permalink
✨ Generate a bug report when unexpected errors happens (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
frinyvonnick authored Jan 8, 2020
1 parent c940075 commit 6d68130
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/gitmoji-changelog-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"hosted-git-info": "^3.0.2",
"immutadot": "^1.0.0",
"inquirer": "^6.3.1",
"issue-reporter": "^0.2.0",
"libnpm": "^1.0.0",
"lodash": "^4.17.11",
"rc": "^1.2.8",
Expand Down
23 changes: 22 additions & 1 deletion packages/gitmoji-changelog-cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const rc = require('rc')
const { generateChangelog, logger } = require('@gitmoji-changelog/core')
const { buildMarkdownFile, getLatestVersion } = require('@gitmoji-changelog/markdown')

const issueReporter = require('issue-reporter')

const { executeInteractiveMode } = require('./interactiveMode')
const getRepositoryInfo = require('./repository')
const pkg = require('../package.json')
Expand Down Expand Up @@ -101,7 +103,26 @@ async function main(options = {}) {
}
logger.success(`changelog updated into ${options.output}`)
} catch (e) {
logger.error(e)
const repository = await getRepositoryInfo()
await issueReporter({
error: e,
user: 'frinyvonnick',
repo: 'gitmoji-changelog',
sections: [
{
title: 'CLI options',
content: options,
},
{
title: 'Project info',
content: projectInfo,
},
{
title: 'Repository info',
content: repository,
},
],
})
}

// force quit (if the latest version request is pending, we don't wait for it)
Expand Down
5 changes: 4 additions & 1 deletion packages/gitmoji-changelog-cli/src/cli.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { generateChangelog, logger } = require('@gitmoji-changelog/core')
const { manifest } = require('libnpm')
const { main } = require('./cli')
const issueReporter = require('issue-reporter')

describe('cli', () => {
const realExitFunction = process.exit
Expand All @@ -18,7 +19,7 @@ describe('cli', () => {

await main(options)

expect(logger.error).toHaveBeenCalled()
expect(issueReporter).toHaveBeenCalled()
})

it('should call process.exit explicitly so promises are not waited for', async () => {
Expand Down Expand Up @@ -90,3 +91,5 @@ jest.mock('../package.json', () => ({
jest.mock('libnpm', () => ({
manifest: jest.fn(),
}))

jest.mock('issue-reporter')
Loading

0 comments on commit 6d68130

Please sign in to comment.