Skip to content

Commit e70b5b0

Browse files
authored
Merge pull request #111 from hkdobrev/tasklist
Show commands being run with listr2
2 parents d465f0f + f469c0e commit e70b5b0

File tree

3 files changed

+24
-38
lines changed

3 files changed

+24
-38
lines changed

package-lock.json

Lines changed: 8 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"dependencies": {
1616
"cosmiconfig": "^9.0.0",
1717
"execa": "^9.5.1",
18+
"listr2": "^8.2.5",
1819
"micromatch": "^4.0.8",
1920
"string-argv": "^0.3.2"
2021
},

src/runCommands.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { execaCommandSync } from 'execa';
2+
import { Listr } from 'listr2';
23

34
const runCommand = (command) => {
4-
process.stdout.write(`${command}\n`);
55
execaCommandSync({
66
preferLocal: true,
77
stdout: 'inherit',
@@ -10,7 +10,18 @@ const runCommand = (command) => {
1010
};
1111

1212
export default (commands) => {
13-
(Array.isArray(commands) ? commands : [commands])
14-
.filter((x) => !!x)
15-
.forEach(runCommand);
13+
const tasks = new Listr(
14+
(Array.isArray(commands) ? commands : [commands])
15+
.filter((x) => !!x)
16+
.map((command) => ({
17+
title: command,
18+
task: () => runCommand(command),
19+
})),
20+
{
21+
concurrent: false,
22+
renderer: 'simple',
23+
}
24+
);
25+
26+
return tasks.run();
1627
};

0 commit comments

Comments
 (0)