bun
bun copied to clipboard
Spaces and quotes aren't handled correctly by bun run
trafficstars
package.json:
{
"scripts": {
"argv": "node -e 'console.log(process.argv)'"
}
}
working on a fix
looks like it's not fully identical to npm behavior (i've to use \" instead of just "):
(this is fish)
Not sure if the following issue is related:
❯ bat -p package.json
{
"name": "blank",
"version": "0.0.3",
"module": "src/index.js",
"scripts": {
"demo": "echo \"test\""
},
"devDependencies": {
"bun-types": "latest"
}
}
❯ npm run demo
> [email protected] demo
> echo "test"
test
❯ bun run demo
$ echo \"test\"
"test"
Basically npm does JSON parsing but bun doesn't seem to do it.
Thanks for reproducing, @kidonng, confirmed it's still an issue as of 0.2.2. We'll get it fixed.
Confirming this is still an issue with 0.5.9:
"scripts": {
"start": "bun run src/app.ts",
"add:article": "curl -X POST -H 'Content-Type: application/json' -d '{\"id\":1,\"title\":\"Test article\",\"body\":\"Test body\"}' http://localhost:4000/articles/"
}
Running this won’t work with Bun:
$ bun run add:article
$ curl -X POST -H 'Content-Type: application/json' -d '{\"id\":1,\"title\":\"Test article\",\"body\":\"Test body\"}' http://localhost:4000/articles/
{
"title": "Bad Request",
"status": 400,
"detail": "Unable to parse JSON: JSON Parse error: Unrecognized token '\\'"
}
But it does with npm:
$ npm run add:article
> @ add:article
> curl -X POST -H 'Content-Type: application/json' -d '{"id":1,"title":"Test article","body":"Test body"}' http://localhost:4000/articles/
The reason is clearly that Bun doesn’t parse JSON as stated above.