moon-cli icon indicating copy to clipboard operation
moon-cli copied to clipboard

TypeError in Git Bash on Windows (10)

Open oBusk opened this issue 8 years ago • 2 comments

Trying to do moon init with Git Bash on Windows results in

readline.js:656
  var strBeforeCursor = this._prompt + this.line.substring(0, this.cursor);
                                                ^

TypeError: Cannot read property 'substring' of undefined
    at Interface._getCursorPos (readline.js:656:49)
    at Interface._moveCursor (readline.js:676:21)
    at Interface.clearLine (readline.js:579:8)
    at Timeout._onTimeout (C:\Users\oBusk\AppData\Roaming\npm\node_modules\moon-cli\src\loader.js:17:8)
    at ontimeout (timers.js:386:14)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)
  • Doing something simple like

    if(rl.line) {
        rl.clearLine();
    }
    

    Will make it atleast output, but something better is probably prefered.

  • Works fine in cmd

  • Also worth mentioning that Git Bash is TTY

    $ node -p -e "Boolean(process.stdout.isTTY)"
    true
    

Versions

npm 4.5.0 node 7.10.0 moon-cli 0.0.10

oBusk avatar May 22 '17 10:05 oBusk

Yeah this is a known issue, and there is nothing I can do about it. It's with the way Git Bash handles input, and it doesn't allow normal interactive input.

On other OS's a third party application can get access to the terminal with interactive input, but on Windows, they require a custom input type.

It should work in Command Prompt. There might be a fix for it on Git Bash, check out nodejs/node#3006

Let me know if any fixes on that issue work.

kbrsh avatar May 23 '17 01:05 kbrsh

Yeah so running node ./bin/moon works fine while running moon has some various issues.

You could wrap the clearlines with if(process.stdout.isTTY) to atleast make it run in those situations.

But if anyone reads this, https://github.com/nodejs/node/issues/3006#issuecomment-171129702 is a good point and worked for me.

oBusk avatar May 23 '17 12:05 oBusk