ioBroker / dev-server

MIT License
14 stars 7 forks source link

Unexpected token with dev-server watch #476

Open simatec opened 2 days ago

simatec commented 2 days ago

I have moved my development environment to a dev server and have the following problem for the backup adapter. I create the dev-server with dev-server setup backitup. If I start the dev-server afterwards with dev-server run backitup everything runs as intended and I can also perform tests in the environment during the backup.

However, if I start with dev-server watch backitup I get the following error message when creating the backup.

[iobroker] error on backup: SyntaxError: Unexpected token ':' Please run "iobroker fix" and reinstall BackItUp

https://github.com/simatec/ioBroker.backitup/blob/eb7e44e9ed49c909ffdbe0b022ec6e433f295627/lib/execute.js#L15

If I then start dev-server run backitup again, the error still occurs.

Only a dev-server setup backitup --force fixes the error, but of course resets everything to default.

Translated with DeepL.com (free version)

Apollon77 commented 2 days ago

Can you maybe log the file content he would execute because seems that the file he reads is invalid JS and maybe log the file heprocesses to see which file i tis which is broken

simatec commented 2 days ago

When the backup is executed, execute.js is executed. The error message occurs when reading in the individual backup scripts line 15.

Is that what you mean?

simatec commented 1 day ago

I think I've got to the root of the problem. The watch mode is mapped and the .js.map files are also in the "scripts" directory If the files are now read, they are of course incorrect. I have now added an if (!file.includes('.map')) to the code

Apollon77 commented 1 day ago

or just ".endsWith(".js")" ?

simatec commented 1 day ago

That works too, of course ;)