Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init created empty .all-contributorsrc #359

Closed
schweden1997 opened this issue Jul 4, 2023 · 4 comments · Fixed by #360
Closed

init created empty .all-contributorsrc #359

schweden1997 opened this issue Jul 4, 2023 · 4 comments · Fixed by #360

Comments

@schweden1997
Copy link
Contributor

Describe the bug
When I use yarn all-contributors init a .all-contributorsrc is created but it contains just an undefined in line 1.
When trying to add a contributor the json-fixer fails, since json cannot contain just an undefined.
When manually creating a .all-contributorsrc and using all-contributors add the command deletes everything in the .all-contributorsrc and adds an undefined.

To Reproduce
Steps to reproduce the behavior:

  1. yarn init -y
  2. yarn add -D all-contributors-cli
  3. git init
  4. yarn all-contributors init (.all-contributorsrc is created, but undefined)
  5. yarn all-contributors add schweden1997 doc,code (this errors)
There's still an error!
There's still an error!
There's still an error!
Error: Expected "[", "false", "null", "true", "{", number, or string but "u" found.
    at doubleCheck (/Users/marcodegaetano/Developer/oss/test-ac/.yarn/cache/json-fixer-npm-1.6.15-ae75b6da33-ae805d5155.zip/node_modules/json-fixer/index.js:29:11)
    at fixJson (/Users/marcodegaetano/Developer/oss/test-ac/.yarn/cache/json-fixer-npm-1.6.15-ae75b6da33-ae805d5155.zip/node_modules/json-fixer/index.js:103:10)
    at doubleCheck (/Users/marcodegaetano/Developer/oss/test-ac/.yarn/cache/json-fixer-npm-1.6.15-ae75b6da33-ae805d5155.zip/node_modules/json-fixer/index.js:27:44)
    at fixJson (/Users/marcodegaetano/Developer/oss/test-ac/.yarn/cache/json-fixer-npm-1.6.15-ae75b6da33-ae805d5155.zip/node_modules/json-fixer/index.js:103:10)
    at doubleCheck (/Users/marcodegaetano/Developer/oss/test-ac/.yarn/cache/json-fixer-npm-1.6.15-ae75b6da33-ae805d5155.zip/node_modules/json-fixer/index.js:27:44)
    at fixJson (/Users/marcodegaetano/Developer/oss/test-ac/.yarn/cache/json-fixer-npm-1.6.15-ae75b6da33-ae805d5155.zip/node_modules/json-fixer/index.js:103:10)
    at doubleCheck (/Users/marcodegaetano/Developer/oss/test-ac/.yarn/cache/json-fixer-npm-1.6.15-ae75b6da33-ae805d5155.zip/node_modules/json-fixer/index.js:27:44)
    at fixJson (/Users/marcodegaetano/Developer/oss/test-ac/.yarn/cache/json-fixer-npm-1.6.15-ae75b6da33-ae805d5155.zip/node_modules/json-fixer/index.js:103:10)
    at doubleCheck (/Users/marcodegaetano/Developer/oss/test-ac/.yarn/cache/json-fixer-npm-1.6.15-ae75b6da33-ae805d5155.zip/node_modules/json-fixer/index.js:27:44)
    at fixJson (/Users/marcodegaetano/Developer/oss/test-ac/.yarn/cache/json-fixer-npm-1.6.15-ae75b6da33-ae805d5155.zip/node_modules/json-fixer/index.js:103:10)

Expected behavior
init command should create correct .all-contributorsrc

Additional context
node -v v20.3.1
node -v v16.20.1 (both tested)
yarn -v 3.6.1
yarn -v 1.22.19 (both tested)
all-contributors -v 6.26.0

Solution
Error seems to occur from:

return pify(fs.writeFile)(configPath, `${formatConfig(content)}\n`)

formatConfig() requires 2 arguments. The first is configPath, second is content. Here the content is passed as the configPath.
Changing this to:

return pify(fs.writeFile)(configPath, `${formatConfig(configPath, content)}\n`);

resolves the issue.

Same thing applied to this:

fs.writeFileSync(configPath, formatConfig(config))

@mprins
Copy link

mprins commented Jul 6, 2023

BTW when running eg. npx all-contributors-cli add mprins code,infra,review,bug,data,doc,maintenance the markdown file is updated properly

@MilesCranmer
Copy link

Thanks; I was seeing this too.

Temporary fix:

    "all-contributors-cli": "6.25.1"

@schweden1997
Copy link
Contributor Author

BTW when running eg. npx all-contributors-cli add mprins code,infra,review,bug,data,doc,maintenance the markdown file is updated properly

For me it works the first time you run the command. Afterwards if trying to add another contributor it stops working due to the empty rc file.

@all-contributors-release-bot
Copy link
Member

🎉 This issue has been resolved in version 6.26.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants