Skip to content

Instantly share code, notes, and snippets.

@Createdd
Last active September 15, 2018 15:04
Show Gist options
  • Select an option

  • Save Createdd/437ac97100c4c0ee0a6b2e077c65ca25 to your computer and use it in GitHub Desktop.

Select an option

Save Createdd/437ac97100c4c0ee0a6b2e077c65ca25 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const fs = require( 'fs' );
const commit = process.argv[2];
const data = fs.readFileSync( commit, { encoding: 'utf8' } );
const [ firstLine ] = data.split( '\n' );
const result = /^[A-Z]+\-\d+ .+$/.test( firstLine );
const errorMessage = `
-----------------------------------------------------
Commit message does not comply to format standards!
Please use the following msg format:
'example'
-----------------------------------------------------
`;
if ( !result ) {
console.log(errorMessage);
process.exit(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment