Skip to content

Commit

Permalink
Add color
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Oct 11, 2024
1 parent e5feffd commit b35522e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
24 changes: 20 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28158,21 +28158,23 @@ async function main() {
!(await hasGitChanged(sourceDir))
) {
core.info(
`Skip sync "${sourceDir}" directory to "${targetBranch}" branch as unchanged`,
yellow(
`Skip sync "${sourceDir}" directory to "${targetBranch}" branch as unchanged`,
),
)
previousLineSkipped = true
continue
}

// Add new line spacing between the last skip and the next sync so it's easier to read
if (previousLineSkipped) {
core.info()
console.log()
previousLineSkipped = false
}

core.info(`Sync "${sourceDir}" directory to "${targetBranch}" branch`)
core.info(blue(`Sync "${sourceDir}" directory to "${targetBranch}" branch`))
await gitForcePush(sourceDir, targetBranch, dryRun, ghToken)
core.info()
console.log()
}
}

Expand Down Expand Up @@ -28401,3 +28403,17 @@ function getParentDirs(sourceDir, cwd) {
return parentDirs
}

/**
* @param {string} str
*/
function blue(str) {
return `\u001b[34m${str}\u001b[0m`
}

/**
* @param {string} str
*/
function yellow(str) {
return `\u001b[33m${str}\u001b[0m`
}

24 changes: 20 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,23 @@ async function main() {
!(await hasGitChanged(sourceDir))
) {
core.info(
`Skip sync "${sourceDir}" directory to "${targetBranch}" branch as unchanged`,
yellow(
`Skip sync "${sourceDir}" directory to "${targetBranch}" branch as unchanged`,
),
)
previousLineSkipped = true
continue
}

// Add new line spacing between the last skip and the next sync so it's easier to read
if (previousLineSkipped) {
core.info()
console.log()
previousLineSkipped = false
}

core.info(`Sync "${sourceDir}" directory to "${targetBranch}" branch`)
core.info(blue(`Sync "${sourceDir}" directory to "${targetBranch}" branch`))
await gitForcePush(sourceDir, targetBranch, dryRun, ghToken)
core.info()
console.log()
}
}

Expand Down Expand Up @@ -288,3 +290,17 @@ function getParentDirs(sourceDir, cwd) {
}
return parentDirs
}

/**
* @param {string} str
*/
function blue(str) {
return `\u001b[34m${str}\u001b[0m`
}

/**
* @param {string} str
*/
function yellow(str) {
return `\u001b[33m${str}\u001b[0m`
}
2 changes: 1 addition & 1 deletion test-fixtures/foo/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log('foo')
console.log('footest')

0 comments on commit b35522e

Please sign in to comment.