forked from django-cms/django-filer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·90 lines (76 loc) · 2.63 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var stylish = require('jshint-stylish');
var Server = require('karma').Server;
var PROJECT_ROOT = __dirname;
var PROJECT_PATH = {
'sass': PROJECT_ROOT + '/filer/private/sass/',
'css': PROJECT_ROOT + '/filer/static/filer/css/',
'js': PROJECT_ROOT + '/filer/static/filer/js/',
'tests': PROJECT_ROOT + '/filer/tests/frontend/',
};
var PROJECT_PATTERNS = {
'sass': PROJECT_PATH.sass + '**/*.scss',
'lint': [
PROJECT_PATH.js + '**/*.js',
PROJECT_ROOT + '/gulpfile.js',
'!' + PROJECT_PATH.js + '**/*.min.js'
]
};
// #############################################################################
// sass
gulp.task('sass', function () {
gulp.src(PROJECT_PATTERNS.sass)
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(sourcemaps.write('/maps'))
.pipe(gulp.dest(PROJECT_PATH.css));
});
gulp.task('sass:watch', function () {
gulp.watch(PROJECT_PATTERNS.sass, ['sass']);
});
// #############################################################################
// LINTING
gulp.task('jscs', function () {
return gulp.src(PROJECT_PATTERNS.lint)
.pipe(jscs())
.pipe(jscs.reporter())
.pipe(jscs.reporter('fail'));
});
gulp.task('jscs:fix', function () {
return gulp.src([PROJECT_PATH.js + '**/*.js', '!' + PROJECT_PATH.js + '**/*.min.js'])
.pipe(jscs({fix: true}))
.pipe(gulp.dest(PROJECT_PATH.js));
});
gulp.task('jscs:watch', function () {
gulp.watch(PROJECT_PATTERNS.lint, ['jscs']);
});
gulp.task('jshint', function () {
return gulp.src(PROJECT_PATTERNS.lint)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('jshint:watch', function () {
gulp.watch(PROJECT_PATTERNS.lint, ['jshint']);
});
gulp.task('js', ['jshint', 'jscs']);
gulp.task('js:watch', function () {
gulp.watch(PROJECT_PATTERNS.lint, ['js']);
});
gulp.task('tests:unit', function (done) {
new Server({
configFile: PROJECT_PATH.tests + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('watch', ['sass:watch', 'js:watch']);
gulp.task('lint', ['js']);
gulp.task('ci', ['js', 'tests:unit']);
gulp.task('default', ['js', 'sass', 'js:watch', 'sass:watch']);