Skip to content

Instantly share code, notes, and snippets.

@hendrixroa
Created January 18, 2020 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hendrixroa/4e0b2caec6f6e4d9371d32045a6b435d to your computer and use it in GitHub Desktop.
Save hendrixroa/4e0b2caec6f6e4d9371d32045a6b435d to your computer and use it in GitHub Desktop.
Get current git message and print into stdout
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