frinyvonnick / gitmoji-changelog

A changelog generator for gitmoji 😜
https://www.npmjs.com/package/gitmoji-changelog
MIT License
390 stars 49 forks source link

UnhandledPromiseRejectionWarning and DeprecationWarning when there is a custom mapping in .gitmoji-changelogrc #164

Closed ivanhercaz closed 4 years ago

ivanhercaz commented 4 years ago

I was trying to work with the new feature (#155), suggested in #154, that allow the users to add a configuration file to customize the commit mapping. I tried to implement this for the next release of a project in which I am working, but when I run gitmoji-changelog --preset generic I get the next traceback:

▶  start     gitmoji-changelog v2.1.0-alpha.6d681303
ℹ  info      update ./CHANGELOG.md
(node:8268) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token ] in JSON at position 282
    at JSON.parse (<anonymous>)
    at exports.parse (/usr/local/lib/node_modules/gitmoji-changelog/node_modules/rc/lib/utils.js:15:17)
    at addConfigFile (/usr/local/lib/node_modules/gitmoji-changelog/node_modules/rc/index.js:30:20)
    at module.exports (/usr/local/lib/node_modules/gitmoji-changelog/node_modules/rc/index.js:44:3)
    at main (/usr/local/lib/node_modules/gitmoji-changelog/src/cli.js:32:31)
    at argv (/usr/local/lib/node_modules/gitmoji-changelog/src/index.js:19:33)
    at Object.yargs.usage.command [as handler] (/usr/local/lib/node_modules/gitmoji-changelog/src/index.js:37:18)
    at Object.runCommand (/usr/local/lib/node_modules/gitmoji-changelog/node_modules/yargs/lib/command.js:238:44)
    at Object.parseArgs [as _parseArgs] (/usr/local/lib/node_modules/gitmoji-changelog/node_modules/yargs/yargs.js:1089:24)
    at Object.parse (/usr/local/lib/node_modules/gitmoji-changelog/node_modules/yargs/yargs.js:542:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/gitmoji-changelog/src/index.js:58:4)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
(node:8268) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8268) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

My .gitmoji-changelogrc contains exactly the next block:

{
  "project": {
    "name": "Buruma",
    "description": "a Pelican theme with Bulma (CSS Framework)",
    "version": "0.1.0"
  },
  "commitMapping": [
    {
      "group": "documentation",
      "label": "Documentation",
      "emojis": [
        "pencil",
        "bulb",
       ]
    },
    {
      "group": "internationalization",
      "label": "Internationalization/localization",
      "emojis": [
        "globe_with_meridians"
       ]
    },
  ]
}

I think the most probably is that I am doing something wrong, but at this moment I don't know what. Could you help me with this issue?

Thanks in advance!

frinyvonnick commented 4 years ago

Hi @ivanhercaz, thank you for the report 👍

I need to improve this error message! The json in your configuration file is not valid. You can use some online tool like JSONLint to check the validity of your json. Here is a valid one:

{
  "project":{
    "name":"Buruma",
    "description":"a Pelican theme with Bulma (CSS Framework)",
    "version":"0.1.0"
  },
  "commitMapping":[
    {
      "group":"documentation",
      "label":"Documentation",
      "emojis":[
        "pencil",
        "bulb"
      ]
    },
    {
      "group":"internationalization",
      "label":"Internationalization/localization",
      "emojis":[
        "globe_with_meridians"
      ]
    }
  ]
}

Does it works with with it?

ivanhercaz commented 4 years ago

The json in your configuration file is not valid.

Ups! That's true. It was very late I think :tired_face: The next time with a similar error I will use a linter to check if the configuration has any error before to report anything.

@frinyvonnick, thank you very much for this feature and your help!

frinyvonnick commented 4 years ago

You're welcome!