-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.ts
43 lines (37 loc) · 910 Bytes
/
list.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
43
import {cli} from 'cli-ux'
import BaseCommand from '../../base-command'
import {projectsConfigLoad} from '../../config'
const sortByName = (a: any, b: any) => {
const nameA = a.name.toUpperCase()
const nameB = b.name.toUpperCase()
if (nameA < nameB) {
return -1
}
if (nameA > nameB) {
return 1
}
return 0
}
export default class ProjectList extends BaseCommand {
static description = 'list projects'
static flags = {
...cli.table.flags()
}
async run() {
const {flags} = this.parse(ProjectList)
const projectsConfig = projectsConfigLoad()
cli.table(projectsConfig.projects.sort(sortByName), {
name: {
minWidth: 7,
},
workDir: {},
mainConfigLocation: {},
default: {
get: row => row.name === projectsConfig.default ? true : ''
}
}, {
printLine: this.log,
...flags, // parsed flags
})
}
}