hasundue / molt

Update dependencies the Deno way
https://jsr.io/@molt
MIT License
71 stars 5 forks source link

cli: `--write` reference `undefined` error in some case #225

Closed Milly closed 1 month ago

Milly commented 1 month ago

Problem

Error occured when running jsr:@molt/cli@0.19.1 --write in https://github.com/Milly/denops-batch-accumulate/tree/875b71c14001c0520cd84f60c3be767c4a80ccbc

Actual

> git clone https://github.com/Milly/denops-batch-accumulate.git
> cd denops-batch-accumulate
> git checkout 875b71c14001c0520cd84f60c3be767c4a80ccbc
> deno run -A jsr:@molt/cli@0.19.1 deno.jsonc --write
� @denops/core 7.0.0 →  7.0.1
� @denops/std 7.0.0 →  7.0.3
� @denops/test 3.0.1 →  3.0.3
� @std/assert 1.0.1 →  1.0.2
� @std/async 1.0.1 →  1.0.2
� @std/testing 1.0.0-rc.5 →  1.0.0
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'replace')
  lines[index] = lines[index].replace(outdated, stringify(updated));
                              ^
    at rewriteImportMap (https://jsr.io/@molt/core/0.19.1/refs.ts:181:31)
    at Module.rewrite (https://jsr.io/@molt/core/0.19.1/refs.ts:137:7)
    at eventLoopTick (ext:core/01_core.js:168:7)
    at async Update.write (https://jsr.io/@molt/core/0.19.1/mod.ts:212:11)
    at async https://jsr.io/@molt/cli/0.19.1/main.ts:92:9
    at async Command.actionHandler (https://jsr.io/@molt/cli/0.19.1/main.ts:90:5)
    at async Command.execute (https://jsr.io/@cliffy/command/1.0.0-rc.5/command.ts:1940:7)
    at async Command.parseCommand (https://jsr.io/@cliffy/command/1.0.0-rc.5/command.ts:1772:14)
    at async https://jsr.io/@molt/cli/0.19.1/main.ts:113:1

Environment

OS: Windows 11 23H2 (Build 22631.3880) Deno: deno 1.45.4 (release, x86_64-pc-windows-msvc) v8 12.7.224.13 typescript 5.5.2 @molt/cli: 0.19.1

hasundue commented 1 month ago

Could you try @molt/cli@0.19.3 as well just in case it's been fixed?

hasundue commented 1 month ago

OK I have reproduced it with both 0.19.1 and 0.19.3. You can workaround it by not specifying deno.jsonc explicitly or specifying it with --config.

Thanks for reporting all the time :pray:

Milly commented 1 month ago

The workaround worked! Thank you!