-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgulpfile.js
73 lines (66 loc) · 2.03 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var gulp = require('gulp');
var gutil = require('gulp-util');
var jscs = require('gulp-jscs');
var jshint = require('gulp-jshint');
var stylish = require('gulp-jscs-stylish');
var validate = require('./lib/validate.js'); // change to require('html-angular-validate')
// Example task for using this module.
gulp.task('htmlangular', function(callback) {
var colors = gutil.colors;
var log = gutil.log;
validate.validate([
"test/html/invalid/full/invalid_regular.html",
"test/html/valid/**"
], {
customattrs: ['fixed-div-label'],
customtags: ['custom-tag'],
wrapping: {
'tr': '<table>{0}</table>'
}
}).then(function(result) {
if (result.allpassed) {
log(colors.green('All files validated successfully'));
callback();
} else {
log(colors.red('Found validation failures'));
for (var i = 0; i < result.failed.length; i++) {
var file = result.failed[i];
log(colors.yellow(file.filepath));
for (var j = 0; j < file.errors.length; j++) {
var err = file.errors[j];
if (err.line !== undefined) {
log(colors.red(' --[' +
err.line +
':' +
err.col +
'] ' +
err.msg));
} else {
log(colors.red(' --[file] ' +
err.msg));
}
}
}
callback(false);
}
}, function(err) {
// Unable to validate files
log(colors.red('htmlangular error: ' + err));
callback(err);
});
});
// Task to lint javascript files.
gulp.task('js-lint', function() {
return gulp.src(['./lib/validate.js', './test/validateTest.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
// Task to style-check javascript files
gulp.task('js-style', function() {
return gulp.src(['./lib/validate.js', './test/validateTest.js'])
.pipe(jscs())
.pipe(stylish());
});
gulp.task('default', gulp.series('htmlangular'));
gulp.task('code-health', gulp.series('js-lint', 'js-style'));