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:

committed by
Igor Minar

parent
a9096437fd
commit
0ba5bebf61
30
tools/gulp-tasks/format.js
Normal file
30
tools/gulp-tasks/format.js
Normal file
@ -0,0 +1,30 @@
|
||||
// clang-format entry points
|
||||
const srcsToFmt = [
|
||||
'modules/@angular/**/*.{js,ts}',
|
||||
'modules/benchmarks/**/*.{js,ts}',
|
||||
'modules/e2e_util/**/*.{js,ts}',
|
||||
'modules/playground/**/*.{js,ts}',
|
||||
'tools/**/*.{js,ts}',
|
||||
'!tools/public_api_guard/**/*.d.ts',
|
||||
'./*.{js,ts}',
|
||||
'!shims_for_IE.js',
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
// Check source code for formatting errors (clang-format)
|
||||
enforce: (gulp) => () => {
|
||||
const format = require('gulp-clang-format');
|
||||
const clangFormat = require('clang-format');
|
||||
return gulp.src(srcsToFmt).pipe(
|
||||
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
|
||||
},
|
||||
|
||||
// Format the source code with clang-format (see .clang-format)
|
||||
format: (gulp) => () => {
|
||||
const format = require('gulp-clang-format');
|
||||
const clangFormat = require('clang-format');
|
||||
return gulp.src(srcsToFmt, {base: '.'})
|
||||
.pipe(format.format('file', clangFormat))
|
||||
.pipe(gulp.dest('.'));
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user