message: build: stop execution on error in `validate-commit-message`
  Stop execution when an error happens in `validate-commit-message` gulp
  task and ensure the error message is printed at the bottom.
  Fixes
  PR Close
diff: // tslint:disable:no-console
  module.exports = (gulp) => () => {
  + try {
  const validateCommitMessage = require('../validate-commit-message');
  const shelljs = require('shelljs');
  + shelljs.set('-e'); // Break on error.
  +
  let baseBranch = 'master';
  const currentVersion = require('semver').parse(require('../../package.json').version);
  const baseHead =
  - shelljs.exec(`git ls-remote --heads origin ${currentVersion.major}.${currentVersion.minor}.*`)
  + shelljs
  + .exec(`git ls-remote --heads origin ${currentVersion.major}.${currentVersion.minor}.*`)
  .trim()
  .split('\n')
  .pop();
  @@ -26,12 +30,11 @@ module.exports = (gulp) => () => {
  // We need to fetch origin explicitly because it might be stale.
  // I couldn't find a reliable way to do this without fetch.
  - result = shelljs.exec(
  + const result = shelljs.exec(
  `git fetch origin ${baseBranch} && git log --reverse --format=%s HEAD ^origin/${baseBranch}`);
  if (result.code) {
  - console.log(result.stderr);
  - process.exit(1);
  + throw new Error(`Failed to fetch commits: ${result.stderr}`);
  }
  const commitsByLine = result.trim().split(/\n/).filter(line => line != '');
  @@ -45,9 +48,12 @@ module.exports = (gulp) => () => {
  const someCommitsInvalid = !commitsByLine.every(validateCommitMessage);
  if (someCommitsInvalid) {
  - console.log('Please fix the failing commit messages before continuing...');
  - console.log(
  + throw new Error(
  + 'Please fix the failing commit messages before continuing...\n' +
  'Commit message guidelines: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines');
  + }
  + } catch (err) {
  + console.error(err);
  process.exit(1);
  }
  };
  