Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing terminal width with elevated processes #4

Closed
jviotti opened this issue Oct 16, 2015 · 2 comments
Closed

Sharing terminal width with elevated processes #4

jviotti opened this issue Oct 16, 2015 · 2 comments

Comments

@jviotti
Copy link
Contributor

jviotti commented Oct 16, 2015

Hi, I'm having some issues running a script that uses inquirer with windosu.

The problem is that within windosu context, inquirer is unable to correctly get the width of the terminal, which is being calculated with cli-width.

I've submitted a PR to inquirer to set a default width of 80 characters which seems to work fine in most cases, however there is a way to make windosu share the correct width with the script it executes:

cli-width (in the latest version, v1.1.0), attempts to read the width from an environment variable (CLI_WIDTH) before going for the default value.

This gives us an opportunity to calculate the width from windosu and pass it to child processes like this:

var cliWidth = require('cli-width');
var child_process = require('child_process');

child_process.spawn('foo', [ 'bar' ], {
    env: {
        CLI_WIDTH: cliWidth()
    }
});

This way, scripts being called with windosu have a way to inherit this value, even if not written in NodeJS.

What do you think?

I'll send a PR for demonstration purposes later today, once I have access to a Windows PC.

@tehsenaus
Copy link
Owner

Sure, this sounds very reasonable. I look forward to seeing the pull request!

@jviotti
Copy link
Contributor Author

jviotti commented Oct 16, 2015

@tehsenaus PR sent!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants