espruino / EspruinoTools

JavaScript library of tools for Espruino - used for the Web IDE, CLI, etc.
Apache License 2.0
150 stars 89 forks source link

espruino-cli: Watch mode with file argument requires process.stdin.rawMode #161

Closed neshanjo closed 1 year ago

neshanjo commented 1 year ago

When using espruino -d device -w file.js --verbose in Git Bash for Windows (Windows 10), I get the following error: serialport error: TypeError: process.stdin.setRawMode is not a function. It seems that Git Bash for windows does not have the raw mode on stdin. However, I do not understand, why in this case (file input) the raw mode is necessary.

I patched my local version with

  if (process.stdin.setRawMode) {
    process.stdin.setRawMode(true);
  }

in line https://github.com/espruino/EspruinoTools/blob/de50f1a7914f746fa04a759e6100625c745898b1/bin/espruino-cli.js#L658 and then in works. This, of course, means that in the direct terminal connection (espruino -d device) special keys do not work. However, without this fix, it does not connect at all.

Using cmd or powershell in Windows fixes the problem since rawMode is available there, so this is not a big deal. It's just that I know many people that use Git bash for developing since it does not only offer useful git support but also has all the handy linux tools available.

gfwilliams commented 1 year ago

Thanks - just added a fix for this!