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

cem errors when package.json has utf-8 BOM #83

Open
Lord-Leonard opened this issue Feb 21, 2024 · 4 comments
Open

cem errors when package.json has utf-8 BOM #83

Lord-Leonard opened this issue Feb 21, 2024 · 4 comments

Comments

@Lord-Leonard
Copy link

Lord-Leonard commented Feb 21, 2024

Description:
When using this plugin the cem analyse command fails because the Package json is not valid json if it has a BOM.

Source:

const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));

Repro:
Add BOM to package.json. -> error

Workaround:
Remove BOM from package.json

Possible solution:
https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/ignoreBOM

@break-stuff
Copy link
Owner

BOMs are not valid in JSON. Do you know where it is coming from and can you remove it?

https://stackoverflow.com/a/38036753

@break-stuff
Copy link
Owner

@Lord-Leonard, were you able to get this resolved?

@Lord-Leonard
Copy link
Author

oh hey sorry.
Like I said removing the bom from package json works.
If you like I can make a pr removing the bom if present allthough it is not valid json I think it will improve usability a lot if some idiot like myself trys to run cem with a bom at the start of the JSON.
At least a meaningfull error messag will do :)

If you would like me to create a PR just let me know ^^

PS next time I will respond sooner, sorry ':D

@break-stuff
Copy link
Owner

Hahaha! No problem! PRs are always welcome.

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

No branches or pull requests

2 participants