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

Add enabled property to a task #42

Closed
SamVerschueren opened this issue Jan 18, 2017 · 1 comment
Closed

Add enabled property to a task #42

SamVerschueren opened this issue Jan 18, 2017 · 1 comment

Comments

@SamVerschueren
Copy link
Owner

SamVerschueren commented Jan 18, 2017

From sindresorhus/np#114 (comment)

It would be nice if we could dynamically make tasks visible or invisible. If invisible, they shouldn't be executed. So maybe the property should be called enabled instead? I had something in mind like

const tasks = new Listr([
    {
        title: 'Install with yarn',
        task: ctx => execa('yarn')
                .catch(() => {
                        ctx.yarn = false;
                });
    },
    {
        title: 'Install with npm',
        visible: ctx => ctx.yarn === false,
        task: () => execa('npm', ['test'])
    }
]);

The function should be synchronous because otherwise we could end up in a state where it looks like the tasks aren't doing any work for 5 seconds for instance.

While I'm typing this, I might be more in favour if enabled. As visible might look like the task is invisible but it will still be executed.

Any remarks, improvements or things I overlooked? Feel free to provide feedback.

// @sindresorhus

@sindresorhus
Copy link

So maybe the property should be called enabled instead?

👍

@SamVerschueren SamVerschueren changed the title Add visibile property to a task Add enabled property to a task Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants