JeromeDane / hearthstone-log-reader

ISC License
3 stars 0 forks source link

hearthstone-log-reader/lib/game.js:40 SyntaxError: Unexpected token : #1

Closed fcasco closed 7 years ago

fcasco commented 7 years ago

Hi, I was trying to user hearthsone-log-reader and this error came up.

This is my code:

const LogReader= require('hearthstone-log-reader');
let fs = require('fs');

logReader = new LogReader();

fs.readFile('hearthstone.log', function(error, buffer) {
    if (error) {
        return console.error(error);
    }

    logParser.parseBuffer(buffer);
});

And this is the output:

/home/facundo/code/deckstats/node_modules/hearthstone-log-reader/lib/game.js:40
    self.opponent = self.players[playerIndex === 0 ? : 1 : 0];
                                                     ^

SyntaxError: Unexpected token :
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/facundo/code/deckstats/node_modules/hearthstone-log-reader/index.js:7:12)

I'm running it no Arch Linux with Node v8.1.2

Hope you can help me sort it out.

JeromeDane commented 7 years ago

self.opponent = self.players[playerIndex === 0 ? : 1 : 0];

Looks like your copy may have gotten an extra : inserted by accident. Is it possible you opened the file and added the colon by accident? ? : 1 : 0 should be ? 1 : 0, which is how it appears when I look at the sour cecode in question.

Hope this helps!

Unfortunately I haven't touched this project in over a year, and am not working on it at all, so I won't really be able to provide more support than this, but you're welcome to do whatever you'd like with it. :)

fcasco commented 7 years ago

I just installed the package with npm, didn't touch any of the files. I fixed my copy locally after seeing the error. I still got some other error, if I can make it work maybe I'll make a fork and push the changes I made.

Thanks for your reply