prompts
prompts copied to clipboard
Git bash: Arrow keys not printing, prints staged lines upon Enter for global package
Describe the bug
Git bash fails to preview stdout as intended when running a global package from command line.
Otherwise, running index.js directly from node in the same directory, node index
, works as expected.
To Reproduce
index.js
#! /usr/bin/env node
const prompts = require('prompts');
prompts({
type: "select",
name: "value",
message: "Hello world",
choices: [
{
title: "Foo",
description: "Foobar.",
value: "1",
},
{
title: "Bar",
description: "Foobaz.",
value: "2",
}
],
})
.then(console.log)
package.json
{
"name": "bashtest",
"version": "1.0.0",
"main": "index.js",
"bin": {
"bashtest": "./index.js"
},
"license": "ISC",
"dependencies": {
"prompts": "^2.4.1"
}
}
Install the package npm i
, then globally npm i -g
and run bashtest
Expected behavior
The staged stdout should be visible and the process should not be left hanging.
System
- OS: Windows 10
- Git bash: 2.31.0
- Node: 15.12.0
Additional context
This issue doesn't occur in VSC's git bash.
Hi @MrGriefs ,
While trying to reproduce the bug I've discovered the issue is probably not really related to global vs local installation but to how the command is triggered:
Steps to reproduce using your index.js
and package.json
files:
-
npm i
-
node index.js
-- works both in raw Git Bash and VS Code -
./index.js
-- works only in VS Code, fails in Git Bash
So I think the root cause might be in how Git Bash interprets the hashbang? I tried changing it to actual node path but the issue remains...