shime / codewars

A missing command line client for Codewars API
http://codewars.com/
44 stars 7 forks source link

Setup is broken #5

Closed jfmercer closed 9 years ago

jfmercer commented 9 years ago

I cannot setup codewars. codewars setup --token "MYTOKEN" always returns the error pictured below. I have tried MYTOKEN both with and without the quotation marks. Additionally, I have tried this on node 0.8.28, 0.10.40, 0.11.16, 0.12.7, 4.0.0, and 4.1.0.

image

If I can help to debug the error, please let me know how.

shime commented 9 years ago

Thanks for reporting, John!

Seems like something funky is happening when trying to read ~/.config/codewars/setup.json, so could you please check the output of

cat ~/.config/codewars/setup.json
jfmercer commented 9 years ago

Hrvoje, thanks for getting back to me. On my box, there is no ~/.config/codewars/setup.json. ~/.config/codewars/ is empty except for one directory, ~/.config/codewars/challenges, which is empty.

Just now, I ran codewars setup --token myToken again. On node 4.1.1, it output the same error message pictured above. On node 0.12.7, it output a slightly different error:

image

Let me know if I can help you debug anything. I'm still relatively new to node & JS generally, but I know enough to get my hands dirty.

Thanks.

jfmercer commented 9 years ago

Ah, here's something. In index.js, line 17, there's no if(fs.exists()) check on ~/.config/codewars/settings.json.

  if (fs.existsSync(C.paths.settings)){
    [No check here for settings.json]
    fs.readFile(C.paths.settings + "settings.json", {encoding: "utf-8"},
jfmercer commented 9 years ago

Based on your code, I manually created a setup.json:

{
    "token": "REDACTED",
    "language": "javascript",
    "strategy": "default"
}

I still get the same error as in my first comment, despite adding the file.

shime commented 9 years ago

I've just published the new version that fixes the checks. Still not sure what's causing this... What OS are you using?

Could you please

npm install -g codewars-client && rm -ri ~/.config/codewars

Let me know if that helps! Thanks.

jfmercer commented 9 years ago

Great! That fixed it. Thanks for your help.

I'm using OS X Yosemite 10.10.5, which uses Darwin Kernel 14.5.0.