1 | "use strict";
|
2 |
|
3 | var eclint = require("eclint");
|
4 | var path = require("path");
|
5 |
|
6 | var sources = [
|
7 | "*",
|
8 | ".*",
|
9 | "{lib,sass,test,build}/**/*"
|
10 | ];
|
11 |
|
12 | module.exports = function(gulp, depends) {
|
13 |
|
14 | gulp.task("eclint", function() {
|
15 | var hasErrors = false;
|
16 | var stream = gulp.src(sources)
|
17 | .pipe(eclint.check({
|
18 | reporter: function(file, message) {
|
19 | hasErrors = true;
|
20 | var relativePath = path.relative(".", file.path);
|
21 | console.error(relativePath + ":", message);
|
22 | }
|
23 | }));
|
24 |
|
25 | stream.on("finish", function() {
|
26 | if (hasErrors) {
|
27 | process.exit(1);
|
28 | }
|
29 | });
|
30 |
|
31 | return stream;
|
32 | });
|
33 |
|
34 | gulp.task("eclint:fix", function() {
|
35 | return gulp.src(sources, {
|
36 | base: "./"
|
37 | })
|
38 | .pipe(eclint.fix())
|
39 | .pipe(gulp.dest("."));
|
40 | });
|
41 | };
|