jsr-io / jsr-npm

A cli tool to make installing packages form jsr.io in node easy
https://npmjs.com/package/jsr
MIT License
92 stars 13 forks source link

Bug: After the second time `bunx jsr add ... ` is failed #35

Closed nakasyou closed 5 months ago

nakasyou commented 5 months ago

I tried bunx jsr add .... The first time will be successful, but after that it will fail.

Reproduction procedure:

bun init
bunx jsr add @std/path
bunx jsr add @std/assert

Log for last command (bunx jsr add @std/assert):

Setting up bunfig.toml...ok
Installing @std/assert...
$ bun add @std/assert@npm:@jsr/std__assert
4 | "@jsr" = "https://npm.jsr.io/"
                                  ^
error: Cannot redefine key
    at /home/nakasyou1103/jsr-hello/bunfig.toml:4:31
SyntaxError: An error occurred while parsing code

I think reason is that it doesn't check if it've already written it when it writes [install.scopes] with jsr add. I think you need a toml parser to fix it perfectly.

Reference code: https://github.com/jsr-io/jsr-npm/blob/main/src/commands.ts