build: modularize the gulp file to be easier to maintain (#14259)

This is a precursor to bringing in some of the gulp tasks from angular.io,
which could lead to the gulpfile becoming unwieldy.
This commit is contained in:
Pete Bacon Darwin
2017-02-03 08:10:41 +00:00
committed by Igor Minar
parent a9096437fd
commit 0ba5bebf61
14 changed files with 354 additions and 264 deletions

View File

@ -0,0 +1,33 @@
module.exports = (gulp) => () => {
const validateCommitMessage = require('../validate-commit-message');
const childProcess = require('child_process');
// We need to fetch origin explicitly because it might be stale.
// I couldn't find a reliable way to do this without fetch.
childProcess.exec(
'git fetch origin master && git log --reverse --format=%s HEAD ^origin/master',
(error, stdout, stderr) => {
if (error) {
console.log(stderr);
process.exit(1);
}
let someCommitsInvalid = false;
let commitsByLine = stdout.trim().split(/\n/);
console.log(`Examining ${commitsByLine.length} commits between HEAD and master`);
if (commitsByLine.length == 0) {
console.log('There are zero new commits between this HEAD and master');
}
someCommitsInvalid = !commitsByLine.every(validateCommitMessage);
if (someCommitsInvalid) {
console.log('Please fix the failing commit messages before continuing...');
console.log(
'Commit message guidelines: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines');
process.exit(1);
}
});
};