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:
- yarn init -y
- yarn add -D all-contributors-cli
- git init
- yarn all-contributors init (.all-contributorsrc is created, but undefined)
- 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)) |
Describe the bug
When I use
yarn all-contributors inita.all-contributorsrcis created but it contains just anundefinedin line 1.When trying to add a contributor the json-fixer fails, since json cannot contain just an undefined.
When manually creating a
.all-contributorsrcand usingall-contributors addthe command deletes everything in the.all-contributorsrcand adds an undefined.To Reproduce
Steps to reproduce the behavior:
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:
cli/src/util/config-file.js
Line 47 in e0a5312
formatConfig() requires 2 arguments. The first is configPath, second is content. Here the content is passed as the configPath.
Changing this to:
resolves the issue.
Same thing applied to this:
cli/src/util/config-file.js
Line 18 in e0a5312