nx
nx copied to clipboard
run-commands cuts last line of inquirer output/console output
Current Behavior
I'm running a custom node script for my executor nx run my-app:my-custom-script
. My script contains an inquirer form. NX cuts the last line of this form.
I'm using:
"inquirer": "^9.1.4"
Sample code of inquirer form (index.mjs
):
[...]
const questions = [
{
type: 'list',
name: 'SAMPLE',
message: 'This is a samle question?',
choices: ['Option1', 'Option2', 'Option3', 'Option4'],
}
];
const answers = await inquirer.prompt(questions);
[...]
project.json
:
[...]
"my-custom-script": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "node build/index.mjs"
}
],
"cwd": "apps/my-app",
"parallel": false
}
}
[...]
Sample output when I run nx run my-app:my-custom-script
:
? This is a samle question? (Use arrow keys)
❯ Option1
Option2
Option3
When I press CTRL+C
the missing output gets printed:
? This is a samle question? (Use arrow keys)
❯ Option1
Option2
Option3
Option4 <--- PRINTED!
> NX ERROR: Something went wrong in run-commands - Command failed: node build/index.mjs
Pass --verbose to see the stacktrace.
Expected Behavior
Console output gets printed with last row.
Expected console output:
? This is a samle question? (Use arrow keys)
❯ Option1
Option2
Option3
Option4
Github Repo
No response
Steps to Reproduce
- Create a node script and put it somewhere in workspace.
- Create target like above in project.json of any app.
- Run new created target
Nx Report
Node : 16.13.0
OS : darwin x64
npm : 8.1.0
nx : 15.2.1
@nrwl/angular : Not Found
@nrwl/cypress : 15.2.1
@nrwl/detox : 15.2.1
@nrwl/devkit : 15.2.1
@nrwl/esbuild : Not Found
@nrwl/eslint-plugin-nx : 15.2.1
@nrwl/expo : 15.2.1
@nrwl/express : Not Found
@nrwl/jest : 15.2.1
@nrwl/js : 15.2.1
@nrwl/linter : 15.2.1
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : 15.2.1
@nrwl/react-native : Not Found
@nrwl/rollup : 15.2.1
@nrwl/schematics : Not Found
@nrwl/storybook : 15.2.1
@nrwl/web : 15.2.1
@nrwl/webpack : 15.2.1
@nrwl/workspace : 15.2.1
typescript : 4.8.4
---------------------------------------
Local workspace plugins:
---------------------------------------
Community plugins:
Failure Logs
No response
Additional Information
No response
this happens when using nx exec
as well. it is particularly annoying when the underlying task prompts the user on that last line.
Any updates on this issue? I am also facing it nx version 15.8.6.
+1
Very annoying problem to have ><
+1
I can't even select an option.
It seems this issue also affects other logged outputs as well, more importantly the last line of running tests interactively on something like jest
+1
I am also experiencing this when using inquirer inside a local executor
I'm seeing the same behavior on most (if not all) other logs as well outside of inquirer
any updates on this? The same thing happens to me.
There's a workaround for this. Instead of the last option being cut off, the separator you will add at the end of the list will be cut off.
import inquirer from 'inquirer';
const questions = [
{
type: 'list',
name: 'SAMPLE',
message: 'This is a samle question?',
choices: [
'Option1',
'Option2',
'Option3',
'Option4',
new inquirer.Separator() // <- add a seperator.
],
}
];
const answers = await inquirer.prompt(questions);
@samrho yeah, that's an ok workaround for inquirer but it's gobbling up a bunch of stdout info that's not necessarily specific to inquirer also which is definitely annoying for observing other things like deployments.
I'm seeing this as well - tried swapping to enquirer but it's behaving the same. I'm using [email protected]
I confirm that with the version [email protected] I reproduce the error.
this happens to me in custom executor. the same function works fine in custom generator 🤔
This should be fixed with the native comand runner in Nx 17.3. I'm going to go ahead with closing this out as the associated work has been merged.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.