Created
January 18, 2020 21:58
-
-
Save hendrixroa/4e0b2caec6f6e4d9371d32045a6b435d to your computer and use it in GitHub Desktop.
Get current git message and print into stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { spawnSync } from 'child_process'; | |
const child = spawnSync('git', ['log', '-1', '--pretty=format:%s']); | |
if (child.error) { | |
// tslint:disable-next-line: no-console | |
console.error(null); | |
process.exit(1); | |
} | |
// tslint:disable-next-line: no-console | |
console.log( | |
JSON.stringify({ | |
message: child.stdout.toString().slice(0, 99), | |
}), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment