{"_id":"@danielkalen/listr","_rev":"3-79e5d495408bac2461785936051a58b5","name":"@danielkalen/listr","description":"Terminal task list (modified to not stop list upon errors when concurrent:true)","dist-tags":{"latest":"0.5.0"},"versions":{"0.5.0":{"name":"@danielkalen/listr","version":"0.5.0","description":"Terminal task list (modified to not stop list upon errors when concurrent:true)","license":"MIT","repository":{"type":"git","url":"git+https://github.com/samverschueren/listr.git"},"author":{"name":"Sam Verschueren","email":"sam.verschueren@gmail.com","url":"github.com/SamVerschueren"},"engines":{"node":">=4"},"scripts":{"test":"clinton && xo && ava"},"files":["index.js","lib"],"keywords":["cli","task","list","tasklist","terminal","term","console","ascii","unicode","loading","indicator","progress","busy","wait","idle"],"dependencies":{"chalk":"^1.1.3","cli-truncate":"^0.2.1","figures":"^1.7.0","indent-string":"^2.1.0","is-promise":"^2.1.0","is-stream":"^1.1.0","log-symbols":"^1.0.2","log-update":"^1.0.2","ora":"^0.2.3","stream-to-observable":"^0.1.0","strip-ansi":"^3.0.1"},"devDependencies":{"rxjs":"^5.0.0-beta.9","delay":"^1.3.1"},"xo":{"esnext":true},"clinton":{"rules":{"editorconfig":"off"}},"gitHead":"12045894bd6f6141a67ef6d3c07f3678d210cd7b","bugs":{"url":"https://github.com/samverschueren/listr/issues"},"homepage":"https://github.com/samverschueren/listr#readme","_id":"@danielkalen/listr@0.5.0","_shasum":"fca7e70801ca074de48746d4033f4b6e62e36efa","_from":".","_npmVersion":"3.8.3","_nodeVersion":"5.10.1","_npmUser":{"name":"danielkalen","email":"d@danielkalen.com"},"dist":{"shasum":"fca7e70801ca074de48746d4033f4b6e62e36efa","tarball":"https://registry.npmjs.org/@danielkalen/listr/-/listr-0.5.0.tgz","integrity":"sha512-d80mKMZ3rptd0wgMuR6N67puOSr1dv+mEI3mfI+EZeomD/zFFR3TlCvlWs/BZJ5Xg5XumTxlipLolMq7WWJSAw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDKXM6B2Vzoyg2Z3Ew7oZI7YfKAu/XRSEg+EDlLHITLxAiEAlad2dpMFslxgsJMbNEeNUBKmGzd8uL+/mACx/Wt3Drg="}]},"maintainers":[{"name":"danielkalen","email":"d@danielkalen.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/listr-0.5.0.tgz_1472667212976_0.7779973230790347"}}},"readme":"# listr [![Build Status](https://travis-ci.org/SamVerschueren/listr.svg?branch=master)](https://travis-ci.org/SamVerschueren/listr)\n\n> Terminal task list\n\n<img src=\"media/screenshot.gif\">\n\n## Install\n\n```\n$ npm install --save listr\n```\n\n\n## Usage\n\n```js\nconst execa = require('execa');\nconst Listr = require('listr');\n\nconst tasks = new Listr([\n\t{\n\t\ttitle: 'Git',\n\t\ttask: () => {\n\t\t\treturn new Listr([\n\t\t\t\t{\n\t\t\t\t\ttitle: 'Checking git status',\n\t\t\t\t\ttask: () => execa.stdout('git', ['status', '--porcelain']).then(result => {\n\t\t\t\t\t\tif (result !== '') {\n\t\t\t\t\t\t\tthrow new Error('Unclean working tree. Commit or stash changes first.');\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttitle: 'Checking remote history',\n\t\t\t\t\ttask: () => execa.stdout('git', ['rev-list', '--count', '--left-only', '@{u}...HEAD']).then(result => {\n\t\t\t\t\t\tif (result !== '0') {\n\t\t\t\t\t\t\tthrow new Error('Remote history differ. Please pull changes.');\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t], {concurrent: true});\n\t\t}\n\t},\n\t{\n\t\ttitle: 'Install package dependencies',\n\t\ttask: () => execa('npm', ['install'])\n\t},\n\t{\n\t\ttitle: 'Run tests',\n\t\ttask: () => execa('npm', ['test'])\n\t},\n\t{\n\t\ttitle: 'Publish package',\n\t\ttask: () => execa('npm', ['publish'])\n\t}\n]);\n\ntasks.run().catch(err => {\n\tconsole.error(err);\n});\n```\n\n\n### Task\n\nA `task` can return different values. If a `task` returns, it means the task was completed successfully. If a task throws an error, the task failed.\n\n```js\nconst tasks = new Listr([\n\t{\n\t\ttitle: 'Success',\n\t\ttask: () => 'Foo'\n\t},\n\t{\n\t\ttitle: 'Failure',\n\t\ttask: () => {\n\t\t\tthrow new Error('Bar')\n\t\t}\n\t}\n]);\n```\n\n\n#### Promises\n\nA `task` can also be async by returning a `Promise`. If the promise resolves, the task completed successfully, it it rejects, the task failed.\n\n```js\nconst tasks = new Listr([\n\t{\n\t\ttitle: 'Success',\n\t\ttask: () => Promise.resolve('Foo')\n\t},\n\t{\n\t\ttitle: 'Failure',\n\t\ttask: () => Promise.reject('Bar')\n\t}\n]);\n```\n\n#### Observable\n\n<img src=\"media/observable.gif\" width=\"250\" align=\"right\">\n\nA `task` can also return an `Observable`. The thing about observables is that it can emit multiple values and can be used to show the output of the\ntask. Please note that only the last line of the output is rendered.\n\n```js\nconst tasks = new Listr([\n\t{\n\t\ttitle: 'Success',\n\t\ttask: () => {\n\t\t\treturn new Observable(observer => {\n\t\t\t\tobserver.next('Foo');\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tobserver.next('Bar');\n\t\t\t\t}, 2000);\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tobserver.complete();\n\t\t\t\t}, 4000);\n\t\t\t});\n\t\t}\n\t},\n\t{\n\t\ttitle: 'Failure',\n\t\ttask: () => Promise.reject(new Error('Bar'))\n\t}\n]);\n```\n\n#### Streams\n\nIt's also possible to return a `stream`. The stream will be converted to an `Observable` and handled as such.\n\n\n#### Skipping tasks\n\n<img src=\"media/skipped.png\" width=\"250\" align=\"right\">\n\nOptionally specify a `skip` function to determine whether a task can be skipped.\n\n- If the `skip` function returns a truthy value or a `Promise` that resolves to a truthy value then the task will be skipped.\n- If the returned value is a string it will be displayed as the reason for skipping the task.\n- If the `skip` function returns a falsey value or a `Promise` that resolves to a falsey value then the task will be executed as normal.\n- If the `skip` function throws or returns a `Promise` that rejects, the task (and the whole build) will fail.\n\n```js\nconst tasks = new Listr([\n\t{\n\t\ttitle: 'Task 1',\n\t\ttask: () => Promise.resolve('Foo')\n\t},\n\t{\n\t\ttitle: 'Can be skipped',\n\t\tskip: () => {\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\treturn 'Reason for skipping';\n\t\t\t}\n\t\t},\n\t\ttask: () => 'Bar'\n\t},\n\t{\n\t\ttitle: 'Task 3',\n\t\ttask: () => Promise.resolve('Bar')\n\t}\n]);\n```\n\n\n\n## API\n\n### Listr([tasks], [options])\n\n#### tasks\n\nType: `object[]`\n\nList of tasks.\n\n##### title\n\nType: `string`\n\nTitle of the task.\n\n##### task\n\nType: `Function`\n\nTask function.\n\n##### skip\n\nType: `Function`\n\nSkip function. Read more about [skipping tasks](#skipping-tasks).\n\n#### options\n\n##### showSubtasks\n\nType: `boolean`<br>\nDefault: `true`\n\nSet to `false` if you want to disable the rendering of the subtasks. Subtasks will be rendered if\nan error occurred in one of them.\n\n##### concurrent\n\nType: `boolean`<br>\nDefault: `false`\n\nSet to `true` if you want tasks to run concurrently.\n\n### Instance\n\n#### add(task)\n\nReturns the instance.\n\n##### task\n\nType: `object` `object[]`\n\nTask object or multiple task objects.\n\n#### run()\n\nStart executing the tasks.\n\n\n## Related\n\n- [ora](https://github.com/sindresorhus/ora) - Elegant terminal spinner\n- [cli-spinners](https://github.com/sindresorhus/cli-spinners) - Spinners for use in the terminal\n\n\n## License\n\nMIT © [Sam Verschueren](https://github.com/SamVerschueren)\n","maintainers":[{"name":"danielkalen","email":"d@danielkalen.com"}],"time":{"modified":"2022-06-12T16:51:56.013Z","created":"2016-08-31T18:13:34.843Z","0.5.0":"2016-08-31T18:13:34.843Z"},"homepage":"https://github.com/samverschueren/listr#readme","keywords":["cli","task","list","tasklist","terminal","term","console","ascii","unicode","loading","indicator","progress","busy","wait","idle"],"repository":{"type":"git","url":"git+https://github.com/samverschueren/listr.git"},"author":{"name":"Sam Verschueren","email":"sam.verschueren@gmail.com","url":"github.com/SamVerschueren"},"bugs":{"url":"https://github.com/samverschueren/listr/issues"},"license":"MIT","readmeFilename":"readme.md"}