Skip to content

Commit

Permalink
Tweak colors
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Nov 2, 2023
1 parent 099a9bb commit dcb925d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/acquire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ async function run() {
if (result.tag === "acquired") {
const key = result.acquiredKey;
const keyDetails = s3Lock.objectKeyDetails(key);
core.info(`Lock ${color.bold(name)} acquired at ${keyDetails}`);
core.info(
`Lock ${color.bold(name)} ${color.green(
"acquired",
)} at ${keyDetails}`,
);
core.setOutput("acquired-at", new Date());
core.setOutput("key", key);
core.saveState("key", key);
Expand All @@ -29,11 +33,19 @@ async function run() {
const keyDetails = s3Lock.objectKeyDetails(key);

if (timer.expired()) {
core.error(`Lock ${color.bold(name)} already held by ${keyDetails}`);
core.error(
`Lock ${color.bold(name)} ${color.red(
"already held",
)} by ${keyDetails}`,
);
throw new Error("Lock was not acquired within timeout");
}

core.info(`Lock ${color.bold(name)} already held by ${keyDetails}`);
core.info(
`Lock ${color.bold(name)} ${color.yellow(
"already held",
)} by ${keyDetails}`,
);
core.info(`Waiting ${timeoutPoll}`);

await timer.sleep(timeoutPoll);
Expand Down
12 changes: 12 additions & 0 deletions src/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ export function gray(x: any): string {
export function cyan(x: any): string {
return `${styles.cyan.open}${x}${styles.cyan.close}`;
}

export function green(x: any): string {
return `${styles.green.open}${x}${styles.green.close}`;
}

export function yellow(x: any): string {
return `${styles.yellow.open}${x}${styles.yellow.close}`;
}

export function red(x: any): string {
return `${styles.red.open}${x}${styles.red.close}`;
}

0 comments on commit dcb925d

Please sign in to comment.