mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-22 12:35:13 +00:00
✨
This commit is contained in:
parent
6ead4d3f95
commit
7c0d22945c
2 changed files with 17 additions and 7 deletions
10
src/index.ts
10
src/index.ts
|
@ -139,10 +139,14 @@ async function init(): Promise<State> {
|
||||||
// Get commit info
|
// Get commit info
|
||||||
try {
|
try {
|
||||||
const commit = await prominence(git).getLastCommit();
|
const commit = await prominence(git).getLastCommit();
|
||||||
log('Info', `commit: ${commit.shortHash} ${commit.author.name} <${commit.author.email}>`);
|
const shortHash: string = commit.shortHash;
|
||||||
log('Info', ` ${new Date(parseInt(commit.committedOn, 10) * 1000)}`);
|
const hash: string = commit.hash;
|
||||||
|
const commitDate = new Date(parseInt(commit.committedOn, 10) * 1000).toLocaleDateString('ja-JP');
|
||||||
|
const commitTime = new Date(parseInt(commit.committedOn, 10) * 1000).toLocaleTimeString('ja-JP');
|
||||||
|
log('Info', `${shortHash}${chalk.gray(hash.substr(shortHash.length))}`, 'LastCommit');
|
||||||
|
log('Info', `${commit.subject} ${chalk.green(`(${commitDate} ${commitTime})`)} ${chalk.blue(`<${commit.author.name}>`)}`, 'LastCommit');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// noop
|
log('Info', `No commit information found`, 'LastCommit');
|
||||||
}
|
}
|
||||||
|
|
||||||
log('Info', 'Initializing...');
|
log('Info', 'Initializing...');
|
||||||
|
|
|
@ -10,8 +10,14 @@ function toLevelColor(level: LogLevel): chalk.ChalkStyle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function log(level: LogLevel, message: string): void {
|
export function log(level: LogLevel, message: string): void;
|
||||||
let color = toLevelColor(level);
|
export function log(level: LogLevel, message: string, domain: string): void;
|
||||||
let time = (new Date()).toLocaleTimeString([], { hour12: false });
|
export function log(level: LogLevel, message: string, domain?: string): void {
|
||||||
console.log(`[${time} ${color.bold(level.toUpperCase())}]: ${message}`);
|
if (typeof domain == 'string') {
|
||||||
|
log(level, `[${domain}] ${message}`);
|
||||||
|
} else {
|
||||||
|
let color = toLevelColor(level);
|
||||||
|
let time = (new Date()).toLocaleTimeString('ja-JP');
|
||||||
|
console.log(`[${time} ${color.bold(level.toUpperCase())}]: ${message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue