Skip to content

Commit f15ba54

Browse files
committed
[github_prs] replace output from console.log to process.stdout.write
1 parent 8e9e368 commit f15ba54

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ This command uses external config file `env.js` file of the next shape
4242
// github-prs/env.js
4343
module.exports = {
4444
authToken: 'auth_token_goes_here', // your GH auth token
45-
creator: 'dev99prblems', // your GH user name aka author
45+
creator: 'dev99problems', // your GH user name aka author
4646
projects: {
4747
work: {
4848
owner: 'apple', // your organization name goes here

commands/github-prs/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ const getSectionProjectsPrs = async (owner, reposList) => {
5656
try {
5757
const { projects } = ENV
5858
const keys = Object.keys;
59-
59+
6060
for (const section of keys(projects)) {
6161
const { owner, repos } = projects[section]
6262

6363
const allPRs = await getSectionProjectsPrs(owner, repos)
6464
const anyPrInSection = !!keys(allPRs)?.length
6565

6666
anyPrInSection && displaySectionName(section)
67-
displayPrs(allPRs)
67+
displayPrs(allPRs, owner)
6868
}
6969
} catch (err) {
7070
console.error(err)

commands/github-prs/output.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,28 @@ const prepareForOutput = (pr, idx) => {
2222
return row
2323
}
2424

25-
const displayPrs = allPRs => {
25+
const displayPrs = (allPRs, owner) => {
2626
Object.keys(allPRs).forEach(repoName => {
2727
const repoPRs = allPRs[repoName]
28-
const repositoryName = `${FgBlue}${repoName}:\n`
29-
console.log(repositoryName)
28+
const projectName = `@${owner}/${repoName}`
29+
const repositoryName = `${FgBlue}${projectName}:\n`
30+
process.stdout.write(repositoryName)
3031

3132
const prsList = repoPRs.map(prepareForOutput).join('')
3233

33-
console.log(prsList)
34+
process.stdout.write(prsList)
3435
})
3536
}
3637

3738
const displaySectionName = section => {
3839
const colorMap = {
3940
work: FgRed,
4041
personal: FgGreen,
42+
default: FgCyan,
4143
}
42-
43-
console.log(colorMap[section] + section.toUpperCase() + ':')
44+
const color = colorMap?.[section] ?? colorMap.default;
45+
46+
process.stdout.write(color + section.toUpperCase() + ':' + '\n')
4447
}
4548

4649
exports.displayPrs = displayPrs

0 commit comments

Comments
 (0)