angular/angular-cli

Schematics does not prompt for input from user in git bash.

Closed this issue ยท 12 comments

๐Ÿž Bug report

Command (mark with an x)

  • [x ] new
  • build
  • serve
  • test
  • e2e
  • generate
  • add for custom Schematics
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

No

No Yes, the previous version in which this bug was not present was: ....

Description

Either it is custom Schematics or angular Schematics, when I try to run this in git bash it does not prompt for values and runs the whole workflow with default values and if no default value is set it either fail if require flag is true otherwise set the empty value for the input.
even though somebody previously raised this issue
#14938
But it was marked closed
I see this as a bug because it behaves differently in a different terminal. the behaviour should be the same across all the terminal. otherwise, some information must be given BCS of which it is happening.

One observation if you create schematics and test it locally by
npm link path to schematics
and then try to run the schematics with command
schematics path:schematic-name
then it works in git bash as well.

A clear and concise description of the problem...

๐Ÿ”ฌ Minimal Reproduction

ng new appName
It works fine in command prompt
on mac terminal
vs code terminal
but with git bash it causes problem it do not ask for user input and run the whole workflow with default values

๐Ÿ”ฅ Exception or Error





๐ŸŒ Your Environment




Angular CLI: 9.0.6
Node: 12.16.1
OS: win32 x64
Angular:
...
Ivy Workspace:
Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.900.6
@angular-devkit/core         9.0.6
@angular-devkit/schematics   9.0.6
@schematics/angular          9.0.6
@schematics/update           0.900.6
rxjs                         6.5.3

Anything else relevant?

Git Bash is a non-interactive terminal which means our prompt library doesn't work with it.

See: SBoudrias/Inquirer.js#570

Why does it work when i run it with schematics path:schematic-name @alan-agius4

That is an interesting detail. Will need to investigate this a bit more.

What version of Windows is being used?

What version of Windows is being used?

Its window 7 enterprise

Screenshot 2020-07-06 at 11 14 20 PM

@alan-agius4 you can have a look at the screenshot attached

In the Schematics CLI, the prompts are being displayed because unlike in the Angular CLI we are not checking whether the terminal is TTY.

Schematics CLI

// Add prompts.
workflow.registry.usePromptProvider(_createPromptProvider());

NG CLI

if (options.interactive !== false && isTTY()) {
workflow.registry.usePromptProvider((definitions: Array<schema.PromptDefinition>) => {
.

Can you try to run node --eval "console.log({stdin: process.stdin.isTTY, stdout: process.stdout.isTTY})"?

Screenshot 2020-07-07 at 5 07 39 PM

Here is the output @alan-agius4

Hi @darpankumar, myself and @clydin had a chat around the issue that you are experiencing and unfortunately this is not something that we can easily replicate as this would require some debugging on your system.

I am going to leave the issue open for a couple of days maybe someone else can replicate this debug and be able to find the root cause of the problem.

Hello,
I have the same problem in git bash on Windows 10 Enterprise Edition, with a custom schematics I have.
There is an interesting behavior I have seen.
If I run yarn ng generate @my/generator:component the promt does not appear and the schema validation fails on the properties that should have been completed in the prompt.
If I run node ./node_modules/@angular/cli/bin/ng generate @my/generator:component the promt appears and everything works as expected.

This is working as expected.

See: nodejs/node#39673

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.