🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

listr2

Package Overview
Dependencies
Maintainers
1
Versions
242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

listr2 - npm Package Compare versions

Comparing version

to
1.3.6

.github/workflows/nodejs.yml

8

dist/interfaces/listr.interface.d.ts

@@ -25,6 +25,6 @@ /// <reference types="node" />

run: (ctx: Ctx, wrapper: ListrTaskWrapper<Ctx>) => Promise<void>;
showSubtasks?: boolean;
collapse?: boolean;
collapseSkips?: boolean;
bottomBar: boolean | number;
options: ListrOptions & {
bottomBar?: ListrTask<Ctx>['bottomBar'];
persistentOutput?: ListrTask<Ctx>['persistentOutput'];
};
spinner?: () => string;

@@ -31,0 +31,0 @@ hasSubtasks(): boolean;

@@ -7,3 +7,3 @@ import { Subject } from 'rxjs';

tasks: ListrTask;
options: ListrOptions;
injectedOptions: ListrOptions;
id: ListrTaskObject<Ctx>['id'];

@@ -17,10 +17,7 @@ title: ListrTaskObject<Ctx>['title'];

prompt: boolean | PromptError;
collapse: boolean;
collapseSkips: boolean;
showSubtasks: boolean;
bottomBar: boolean | number;
private persistentOutput;
options: ListrTaskObject<Ctx>['options'];
exitOnError: boolean;
private enabled;
private enabledFn;
constructor(listr: Listr<Ctx>, tasks: ListrTask, options: ListrOptions);
constructor(listr: Listr<Ctx>, tasks: ListrTask, injectedOptions: ListrOptions);
set state$(state: StateConstants);

@@ -27,0 +24,0 @@ check(ctx: Ctx): Promise<void>;

@@ -19,18 +19,15 @@ "use strict";

class Task extends rxjs_1.Subject {
constructor(listr, tasks, options) {
var _a, _b, _c, _d, _e;
constructor(listr, tasks, injectedOptions) {
var _a, _b, _c, _d, _e, _f;
super();
this.listr = listr;
this.tasks = tasks;
this.options = options;
this.injectedOptions = injectedOptions;
this.id = uuid_1.v4();
this.title = (_a = this.tasks) === null || _a === void 0 ? void 0 : _a.title;
this.task = this.tasks.task;
this.collapse = this.options.collapse;
this.collapseSkips = this.options.collapseSkips;
this.showSubtasks = this.options.showSubtasks;
this.persistentOutput = (_b = this.tasks) === null || _b === void 0 ? void 0 : _b.persistentOutput;
this.skip = ((_c = this.tasks) === null || _c === void 0 ? void 0 : _c.skip) || (() => false);
this.bottomBar = (_d = this.tasks) === null || _d === void 0 ? void 0 : _d.bottomBar;
this.enabledFn = ((_e = this.tasks) === null || _e === void 0 ? void 0 : _e.enabled) || (() => true);
this.options = Object.assign({ persistentOutput: (_b = this.tasks) === null || _b === void 0 ? void 0 : _b.persistentOutput, bottomBar: (_c = this.tasks) === null || _c === void 0 ? void 0 : _c.bottomBar }, this.injectedOptions);
this.skip = ((_d = this.tasks) === null || _d === void 0 ? void 0 : _d.skip) || (() => false);
this.skip = ((_e = this.tasks) === null || _e === void 0 ? void 0 : _e.skip) || (() => false);
this.enabledFn = ((_f = this.tasks) === null || _f === void 0 ? void 0 : _f.enabled) || (() => true);
}

@@ -78,3 +75,3 @@ set state$(state) {

isBottomBar() {
if (typeof (this === null || this === void 0 ? void 0 : this.bottomBar) === 'number' || typeof this.bottomBar === 'boolean') {
if (typeof (this === null || this === void 0 ? void 0 : this.options.bottomBar) === 'number' || typeof this.options.bottomBar === 'boolean') {
return true;

@@ -84,3 +81,3 @@ }

haspersistentOutput() {
if (this.persistentOutput === true) {
if (this.options.persistentOutput === true) {
return true;

@@ -102,6 +99,4 @@ }

const handleResult = (result) => {
var _a;
if (result instanceof listr_1.Listr) {
result.options = Object.assign(this.options, result.options);
result.exitOnError = (_a = result.options) === null || _a === void 0 ? void 0 : _a.exitOnError;
result.rendererClass = renderer_1.getRenderer('silent');

@@ -168,3 +163,3 @@ this.subtasks = result.tasks;

wrapper.report(error);
if (this.listr.exitOnError !== false) {
if (this.listr.options.exitOnError !== false) {
throw error;

@@ -171,0 +166,0 @@ }

@@ -7,3 +7,2 @@ import { ListrClass, ListrContext, ListrError, ListrOptions, ListrRendererClass, ListrTask } from './interfaces/listr.interface';

err: ListrError[];
exitOnError: ListrOptions['exitOnError'];
rendererClass: ListrRendererClass<Ctx>;

@@ -10,0 +9,0 @@ private concurrency;

@@ -7,2 +7,3 @@ "use strict";

const p_map_1 = __importDefault(require("p-map"));
const state_constants_1 = require("./constants/state.constants");
const listr_interface_1 = require("./interfaces/listr.interface");

@@ -36,4 +37,12 @@ const task_1 = require("./lib/task");

this.rendererClass = renderer_1.getRenderer(this.options.renderer, this.options.nonTTYRenderer);
this.exitOnError = this.options.exitOnError;
this.add(task || []);
process.on('SIGINT', async () => {
await Promise.all(this.tasks.map(async (task) => {
if (task.isPending()) {
task.state$ = state_constants_1.stateConstants.FAILED;
}
}));
this.renderer.end(new Error('Interrupted.'));
process.exit(127);
}).setMaxListeners(0);
}

@@ -70,3 +79,3 @@ add(task) {

this.renderer.end(error);
if (this.exitOnError !== false) {
if (this.options.exitOnError !== false) {
throw error;

@@ -73,0 +82,0 @@ }

@@ -47,7 +47,11 @@ "use strict";

if (task.hasTitle()) {
let taskTitle = task.title;
if (task.isSkipped() && (task === null || task === void 0 ? void 0 : task.collapseSkips)) {
taskTitle = !task.isSkipped() ? `${task === null || task === void 0 ? void 0 : task.title}` : `${task === null || task === void 0 ? void 0 : task.output} ${chalk_1.default.dim('[SKIPPED]')}`;
if (task.isSkipped() && (task === null || task === void 0 ? void 0 : task.options.collapseSkips)) {
task.title = !task.isSkipped() ? `${task === null || task === void 0 ? void 0 : task.title}` : `${task === null || task === void 0 ? void 0 : task.output} ${chalk_1.default.dim('[SKIPPED]')}`;
}
output.push(this.formatString(taskTitle, this.getSymbol(task), level));
if (!(tasks.some((task) => task.hasFailed()) && !task.hasFailed() && task.options.exitOnError !== false && !(task.isCompleted() || task.isSkipped()))) {
output.push(this.formatString(task.title, this.getSymbol(task), level));
}
else {
output.push(this.formatString(task.title, chalk_1.default.red(figures_1.default.squareSmallFilled), level));
}
}

@@ -63,3 +67,3 @@ if (task === null || task === void 0 ? void 0 : task.output) {

this.bottomBar[task.id].data = [];
this.bottomBar[task.id].items = typeof task.bottomBar === 'boolean' ? 1 : task.bottomBar;
this.bottomBar[task.id].items = typeof task.options.bottomBar === 'boolean' ? 1 : task.options.bottomBar;
}

@@ -73,3 +77,3 @@ if (!(data === null || data === void 0 ? void 0 : data.some((element) => this.bottomBar[task.id].data.includes(element)))) {

}
else if (task.isSkipped() && task.collapseSkips === false) {
else if (task.isSkipped() && task.options.collapseSkips === false) {
output = [...output, ...this.dumpData(task, level)];

@@ -80,5 +84,6 @@ }

|| task.isCompleted() && !task.hasTitle()
|| task.isCompleted() && task.collapse === false && task.hasSubtasks() && !task.subtasks.some((subtask) => subtask.collapse === true)
|| task.isCompleted() && task.hasSubtasks() && task.subtasks.some((subtask) => subtask.collapse === false))
&& task.showSubtasks !== false && task.hasSubtasks()) {
|| task.isCompleted() && task.options.collapse === false && task.hasSubtasks() && !task.subtasks.some((subtask) => subtask.options.collapse === true)
|| task.isCompleted() && task.hasSubtasks() && task.subtasks.some((subtask) => subtask.options.collapse === false)
|| task.isCompleted() && task.hasSubtasks() && task.subtasks.some((subtask) => subtask.hasFailed()))
&& task.options.showSubtasks !== false && task.hasSubtasks()) {
const subtaskLevel = !task.hasTitle() ? level : level + 1;

@@ -136,14 +141,17 @@ const subtaskRender = this.multiLineRenderer(task.subtasks, subtaskLevel);

if (task.isPending() && !data) {
return this.options.showSubtasks !== false && task.hasSubtasks() ? chalk_1.default.yellow(figures_1.default.pointer) : chalk_1.default.yellowBright(task.spinner());
return task.options.showSubtasks !== false && task.hasSubtasks() ? chalk_1.default.yellow(figures_1.default.pointer) : chalk_1.default.yellowBright(task.spinner());
}
if (task.isCompleted() && !data) {
if (task.hasSubtasks() && task.subtasks.some((subtask) => subtask.hasFailed())) {
return chalk_1.default.yellow(figures_1.default.warning);
}
return chalk_1.default.green(figures_1.default.tick);
}
if (task.hasFailed() && !data) {
return task.hasSubtasks() ? chalk_1.default.red(figures_1.default.play) : chalk_1.default.red(figures_1.default.cross);
return task.hasSubtasks() ? chalk_1.default.red(figures_1.default.pointer) : chalk_1.default.red(figures_1.default.cross);
}
if (task.isSkipped() && !data && task.collapseSkips === false) {
if (task.isSkipped() && !data && task.options.collapseSkips === false) {
return chalk_1.default.yellow(figures_1.default.warning);
}
else if (task.isSkipped() && (data || task.collapseSkips)) {
else if (task.isSkipped() && (data || task.options.collapseSkips)) {
return chalk_1.default.yellow(figures_1.default.arrowDown);

@@ -150,0 +158,0 @@ }

{
"name": "listr2",
"version": "1.3.5",
"version": "1.3.6",
"description": "Terminal task list reborn!",

@@ -5,0 +5,0 @@ "license": "MIT",

Listr2
====
[![Build Status](https://cd.ev.kilic.dev/api/badges/cenk1cenk2/listr2/status.svg)](https://cd.ev.kilic.dev/cenk1cenk2/listr2)
[![Version](https://img.shields.io/npm/v/listr2.svg)](https://npmjs.org/package/listr2)
[![Downloads/week](https://img.shields.io/npm/dw/listr2.svg)](https://npmjs.org/package/listr2)
[![Build Status](https://cd.ev.kilic.dev/api/badges/cenk1cenk2/listr2/status.svg)](https://cd.ev.kilic.dev/cenk1cenk2/listr2)

@@ -8,0 +8,0 @@ This is the expanded and re-written in Typescript version of the beautiful plugin by [Sam Verschueren](https://github.com/SamVerschueren) called [Listr](https://github.com/SamVerschueren/listr). Fully backwards compatible with the Listr itself but with more features.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet