generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpulls.ts
33 lines (27 loc) · 930 Bytes
/
pulls.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
import terminalLink from 'terminal-link'
import BaseCommand from '../base-command.js'
import {Github} from '../github.js'
import {Repos} from '../repos.js'
import {printTable} from '../table.js'
export default class Pulls extends BaseCommand {
public static description =
'List all your pull requests for added repositories. Requires GH_TOKEN to be set in the environment.'
public static examples = ['<%= config.bin %> <%= command.id %>']
public async run(): Promise<void> {
const repos = await new Repos().init()
const pulls = await new Github().userPulls({repos: repos.values()})
const data = Object.values(pulls).map((p) => ({
pr: terminalLink(`#${p.number}`, p.url),
repo: p.repo,
title: p.title,
}))
printTable({
columns: ['repo', 'title', {key: 'pr', name: 'PR'}],
data,
sort: {
repo: 'asc',
},
title: 'Pull Requests',
})
}
}