-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Describe the bug
At p5.js we just switched to having our contributors list in a separate file because it was getting quite large. We noticed after doing this that the all-contributors bot stopped being able to add contributors. The problem could be reproduced with the all-contributors CLI locally too. It worked correctly again after adding a title to the markdown file.
To Reproduce
Steps to reproduce the behavior:
-
Create
CONTRIBUTORS.mdthat looks like this, with nothing at the top of the file before the comment:<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->
-
In
.all-contributorsrc, point to that file:"files": [ "CONTRIBUTORS.md" ],
-
Run
all-contributors add someusername codeto try to add a contributor -
I get this error:
RangeError: Invalid count value: -1
at String.repeat (<anonymous>)
at /usr/local/lib/node_modules/all-contributors-cli/dist/generate/index.js:19:186
at /usr/local/lib/node_modules/all-contributors-cli/node_modules/lodash/lodash.min.js:57:276
at module.exports (/usr/local/lib/node_modules/all-contributors-cli/dist/generate/index.js:75:78)
at /usr/local/lib/node_modules/all-contributors-cli/dist/cli.js:33:28
at async Promise.all (index 0)
Expected behavior
It should be able to add an entry to the table.
Additional context
Adding anything beforehand, e.g. a title to the markdown file, makes it work.
I think there's just an assumption that there is content before, so it tries to index a string at index -1. Maybe wrapping in Math.max(idx, 0) would be sufficient.