This repository has been archived by the owner on Jun 7, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
gulpfile.babel.js
111 lines (91 loc) · 2.76 KB
/
gulpfile.babel.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'use strict';
var gscan = require("gscan");
import _ from 'lodash';
import autoprefix from 'gulp-autoprefixer';
import bourbon from 'bourbon';
import chalk from 'chalk';;
import gulp from 'gulp';
import jshint from 'gulp-jshint';
import neat from 'bourbon-neat';
import pkg from './package.json';
import run from 'run-sequence';
import sass from 'gulp-sass';
import sasslint from 'gulp-sass-lint';
import stylish from 'jshint-stylish';
import zip from 'gulp-zip';
const paths = {
scss: './assets/stylesheets/**/*.scss',
css: './assets/css/',
js: './assets/javascripts/**/*.js',
};
const levels = {
error: chalk.red,
warning: chalk.yellow,
recommendation: chalk.yellow,
feature: chalk.green
};
gulp.task('sass', () =>
gulp.src(paths.scss)
.pipe(sass({
sourcemaps: true,
includePaths: [bourbon.includePaths, neat.includePaths]
}).on('error', sass.logError))
.pipe(autoprefix('last 2 versions'))
.pipe(gulp.dest(paths.css))
);
gulp.task('sasslint', () =>
gulp.src([ paths.scss ])
.pipe(sasslint({
options: {
formatter: 'stylish',
},
configFile: '.sass-lint.yml',
}))
.pipe(sasslint.format())
);
gulp.task('jshint', () =>
gulp.src(paths.js)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
);
gulp.task('scan', () => {
function outputResult(result) {
console.log('-', levels[result.level](result.level), result.rule);
}
function outputResults(theme) {
theme = gscan.format(theme);
console.log(chalk.bold.underline('\nRule Report:'));
if (!_.isEmpty(theme.results.error)) {
console.log(chalk.red.bold.underline('\n! Must fix:'));
_.each(theme.results.error, outputResult);
}
if (!_.isEmpty(theme.results.warning)) {
console.log(chalk.yellow.bold.underline('\n! Should fix:'));
_.each(theme.results.warning, outputResult);
}
if (!_.isEmpty(theme.results.recommendation)) {
console.log(chalk.red.yellow.underline('\n? Consider fixing:'));
_.each(theme.results.recommendation, outputResult);
}
if (!_.isEmpty(theme.results.pass)) {
console.log(chalk.green.bold.underline('\n\u2713', theme.results.pass.length, 'Passed Rules'));
}
console.log('\n...checks complete.');
};
gscan.checkZip({
path: `./${pkg.name}.zip`,
name: pkg.name
}).then(outputResults);
});
gulp.task('zip', () =>
gulp.src(['./**/*', '!./node_modules/**', `!./${pkg.name}.zip`])
.pipe(zip(`./${pkg.name}.zip`))
.pipe(gulp.dest('.'))
);
gulp.task('default', ['sass', 'sasslint', 'jshint'], () =>
gulp.watch(paths.scss, ['sass', 'sasslint']),
gulp.watch(paths.js, ['jshint'])
);
gulp.task('deploy', (callback) =>
run('sass', 'zip', 'scan', callback)
);