-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
index.ts
42 lines (34 loc) · 973 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {
Arguments,
Command,
CommandConfigOptions,
filterProjects,
listableFormatProjects,
output,
} from "@lerna/core";
export function factory(argv: Arguments<CommandConfigOptions>) {
return new ListCommand(argv);
}
export class ListCommand extends Command {
private result?: { text: string; count: number };
override get requiresGit() {
return false;
}
override async initialize() {
const filteredProjects = filterProjects(this.projectGraph, this.execOpts, this.options);
this.result = listableFormatProjects(filteredProjects, this.projectGraph, this.options);
}
override execute() {
// piping to `wc -l` should not yield 1 when no packages matched
if (this.result?.text.length) {
output(this.result.text);
}
this.logger.success(
"found",
"%d %s",
this.result?.count,
this.result?.count === 1 ? "package" : "packages"
);
process.stdout.end(() => process.exit(0));
}
}