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

How to allow prompting for password? #145

Open
kykungz opened this issue May 26, 2020 · 3 comments
Open

How to allow prompting for password? #145

kykungz opened this issue May 26, 2020 · 3 comments

Comments

@kykungz
Copy link

kykungz commented May 26, 2020

I used listr to execute commands with execa, which some of commands required sudo permission which asks for password.

However, it seems like the loading state of listr task is overriding my password prompts, giving no feedback to users to type in the password. Although I can still type in the password and press Enter, it is hard to determine that they are prompting for password.

Any solution?

@Nasseratic
Copy link

seams no more maintainers here 😞

@LitoMore
Copy link
Collaborator

LitoMore commented Sep 4, 2020

Could you make a case for me then I can work on it?

@mehdi-sh-hm
Copy link

You can do something like this but if you change one thing in source code of project 😐

import { UpdateRenderer, render /** This is the change I was talking about */ } from 'listr-update-renderer'

/* Some state management to export to change the state */
export const RenderState = {
  pause: false
}

export class MyRenderer extends UpdateRenderer {

  _id;
  _tasks;
  _options;

  render() {
    if (this._id) {
       // Do not render if we are already rendering
       return;
    }

    this._id = setInterval(() => {
       if (RenderState.pause) {
          return
       }
       render(this._tasks, this._options);
    }, 100);
  }

}

then you can do something like this in your task

task: async (ctx, task) => {
  RenderState.pause = true;
  await cli.confirm('Are you sure?')
  RenderState.pause = false;
}

💥

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

4 participants