-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
75 lines (64 loc) · 1.59 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
74
75
/* eslint-env node */
'use strict';
var chalk = require('chalk');
var gulp = require('gulp');
var gutil = require('gulp-util');
var sassdoc = require('sassdoc');
var sasslint = require('gulp-sass-lint');
var paths = {
TEST_DIR: 'test/',
SASS_DIR: 'sass/',
IGNORE: [
'!**/.#*',
'!**/flycheck_*'
],
init: function () {
this.SASS = [
this.SASS_DIR + '**/*.scss'
].concat(this.IGNORE);
this.ALL_SASS = [
this.SASS_DIR + '**/*.scss',
this.TEST_DIR + '**/*.scss'
].concat(this.IGNORE);
return this;
}
}.init();
var onError = function (err) {
gutil.log(chalk.red(err.message));
gutil.beep();
this.emit('end');
};
var sasslintTask = function (src, failOnError, log) {
if (log) {
gutil.log('Running', '\'' + chalk.cyan('sasslint ' + src) + '\'...');
}
var stream = gulp.src(src)
.pipe(sasslint())
.pipe(sasslint.format())
.pipe(sasslint.failOnError());
if (!failOnError) {
stream.on('error', onError);
}
return stream;
};
gulp.task('sasslint', function () {
return sasslintTask(paths.ALL_SASS, true);
});
gulp.task('sasslint-nofail', function () {
return sasslintTask(paths.ALL_SASS);
});
gulp.task('sassdoc', function () {
return gulp.src(paths.SASS)
.pipe(sassdoc());
});
gulp.task('watch', function () {
gulp.watch(paths.SASS, ['sassdoc']);
// lint scss on changes
gulp.watch(paths.ALL_SASS, function (ev) {
if (ev.type === 'added' || ev.type === 'changed') {
sasslintTask(ev.path, false, true);
}
});
// lint all scss when rules change
gulp.watch('**/.sass-lint.yml', ['sasslint-nofail']);
});