diff options
| author | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2016-12-31 03:29:24 +0900 |
|---|---|---|
| committer | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2016-12-31 03:29:24 +0900 |
| commit | eb10c3a8dc9f0a27bba8123696c69047b55bd05f (patch) | |
| tree | 3227bd8756f91422b33d7eaa57b8ba94a8633d09 /src/utils | |
| parent | Rename DependencyChecker to DependencyInfo (diff) | |
| download | misskey-eb10c3a8dc9f0a27bba8123696c69047b55bd05f.tar.gz misskey-eb10c3a8dc9f0a27bba8123696c69047b55bd05f.tar.bz2 misskey-eb10c3a8dc9f0a27bba8123696c69047b55bd05f.zip | |
Extract LastCommitInfo
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/lastCommitInfo.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/utils/lastCommitInfo.ts b/src/utils/lastCommitInfo.ts new file mode 100644 index 0000000000..0cdd177595 --- /dev/null +++ b/src/utils/lastCommitInfo.ts @@ -0,0 +1,21 @@ +import Logger from './logger'; +import * as chalk from 'chalk'; +const prominence = require('prominence'); +const git = require('git-last-commit'); + +export default class LastCommitInfo { + static async show(): Promise<void> { + let logger = new Logger('LastCommit'); + try { + const commit = await prominence(git).getLastCommit(); + const shortHash: string = commit.shortHash; + 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'); + logger.info(`${shortHash}${chalk.gray(hash.substr(shortHash.length))}`); + logger.info(`${commit.subject} ${chalk.green(`(${commitDate} ${commitTime})`)} ${chalk.blue(`<${commit.author.name}>`)}`); + } catch (e) { + logger.info('No commit information found'); + } + } +} |