forked from umts/pvta-multiplatform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
96 lines (80 loc) · 2.44 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
var gulp = require('gulp');
var path = require('path');
var eslint = require('gulp-eslint');
var cache = require('gulp-cached');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var gulpIf = require('gulp-if');
var paths = {
sass: ['./scss/**/*.scss']
};
gulp.task('sass', function(done) {
gulp.src('./scss/ionic.app.scss')
.pipe(sass())
.on('error', sass.logError)
.pipe(gulp.dest('./www/css/'))
.pipe(minifyCss({
keepSpecialComments: 0
}))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('./www/css/'))
.on('end', done);
});
gulp.task('watch', function() {
gulp.watch(paths.sass, ['sass']);
});
function isFixed(file) {
// Has ESLint fixed the file contents?
return file.eslint != null && file.eslint.fixed;
}
gulp.task('lint-n-fix', function() {
return gulp.src('www/pages/**/*.js')
.pipe(eslint({
fix: true
}))
.pipe(eslint.format())
// if fixed, write the file to dest
.pipe(gulpIf(isFixed, gulp.dest('www/pages')));
});
gulp.task('lint-watch', function() {
// Lint only files that change after this watch starts
var lintAndPrint = eslint();
// format results with each file, since this stream won't end.
lintAndPrint.pipe(eslint.formatEach());
return gulp.watch('www/pages/**/*.js', function(event) {
if (event.type !== 'deleted') {
gulp.src(event.path)
.pipe(lintAndPrint, {end: false});
}
});
});
gulp.task('cached-lint', function() {
// Read all js files within test/fixtures
return gulp.src('www/pages/**/*.js')
.pipe(cache('eslint'))
// Only uncached and changed files past this point
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.result(function(result) {
if (result.warningCount > 0 || result.errorCount > 0) {
// If a file has errors/warnings remove uncache it
delete cache.caches.eslint[path.resolve(result.filePath)];
}
}));
});
// Run the "cached-lint" task initially...
gulp.task('cached-lint-watch', ['cached-lint'], function() {
// ...and whenever a watched file changes
return gulp.watch('www/pages/**/*.js', ['cached-lint'], function(event) {
if (event.type === 'deleted' && cache.caches.eslint) {
// remove deleted files from cache
delete cache.caches.eslint[event.path];
}
});
});
gulp.task('default', ['cached-lint-watch', 'sass']);