Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

listr

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

listr

Terminal task list

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8M
increased by10.26%
Maintainers
1
Weekly downloads
 
Created

What is listr?

Listr is a Node.js library for creating elegant CLI task lists. It allows you to define a series of tasks that can be executed sequentially or concurrently, with support for dynamic updates, subtasks, and conditional execution.

What are listr's main functionalities?

Sequential Task Execution

This feature allows you to define and execute tasks sequentially. Each task is represented as an object with a title and a task function that returns a promise.

const Listr = require('listr');

const tasks = new Listr([
  {
    title: 'Task 1',
    task: () => Promise.resolve('Task 1 completed')
  },
  {
    title: 'Task 2',
    task: () => Promise.resolve('Task 2 completed')
  }
]);

tasks.run().then(() => {
  console.log('All tasks completed');
}).catch(err => {
  console.error(err);
});

Concurrent Task Execution

This feature allows you to execute tasks concurrently by setting the 'concurrent' option to true. All tasks will run in parallel.

const Listr = require('listr');

const tasks = new Listr([
  {
    title: 'Task 1',
    task: () => Promise.resolve('Task 1 completed')
  },
  {
    title: 'Task 2',
    task: () => Promise.resolve('Task 2 completed')
  }
], { concurrent: true });

tasks.run().then(() => {
  console.log('All tasks completed');
}).catch(err => {
  console.error(err);
});

Conditional Task Execution

This feature allows you to conditionally skip tasks based on a condition. The 'skip' function can return a string to indicate why the task was skipped.

const Listr = require('listr');

const tasks = new Listr([
  {
    title: 'Task 1',
    task: () => Promise.resolve('Task 1 completed')
  },
  {
    title: 'Task 2',
    task: () => Promise.resolve('Task 2 completed'),
    skip: () => {
      if (someCondition) {
        return 'Task 2 skipped';
      }
    }
  }
]);

tasks.run().then(() => {
  console.log('All tasks completed');
}).catch(err => {
  console.error(err);
});

Subtasks

This feature allows you to define subtasks within a main task. Each subtask is represented as an object within a nested Listr instance.

const Listr = require('listr');

const tasks = new Listr([
  {
    title: 'Main Task',
    task: () => new Listr([
      {
        title: 'Subtask 1',
        task: () => Promise.resolve('Subtask 1 completed')
      },
      {
        title: 'Subtask 2',
        task: () => Promise.resolve('Subtask 2 completed')
      }
    ])
  }
]);

tasks.run().then(() => {
  console.log('All tasks completed');
}).catch(err => {
  console.error(err);
});

Other packages similar to listr

Keywords

FAQs

Package last updated on 29 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc