forked from django-cms/django-filer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·121 lines (109 loc) · 3.83 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
'use strict';
var gulp = require('gulp');
var gulpsync = require('gulp-sync')(gulp);
var gutil = require('gulp-util');
var sass = require('gulp-sass');
var iconfont = require('gulp-iconfont');
var iconfontCss = require('gulp-iconfont-css');
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/',
'icons': PROJECT_ROOT + '/filer/static/filer/fonts/'
};
var PROJECT_PATTERNS = {
'sass': PROJECT_PATH.sass + '**/*.scss',
icons: [
PROJECT_PATH.icons + '/src/*.svg'
],
'lint': [
PROJECT_PATH.js + '**/*.js',
'!' + PROJECT_PATH.js + '**/*.min.js',
PROJECT_PATH.tests + 'unit/**/*.js',
'!' + PROJECT_PATH.tests + 'unit/**/*.min.js',
PROJECT_ROOT + '/gulpfile.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']);
});
// #############################################################################
// Icons
gulp.task('icons', function () {
gulp.src(PROJECT_PATTERNS.icons)
.pipe(iconfontCss({
fontName: 'django-filer-iconfont',
fontPath: '../fonts/',
path: PROJECT_PATH.sass + '/libs/_iconfont.scss',
targetPath: '../../../private/sass/layout/_iconography.scss'
}))
.pipe(iconfont({
fontName: 'django-filer-iconfont',
normalize: true
}))
.on('glyphs', function (glyphs, options) {
gutil.log.bind(glyphs, options);
})
.pipe(gulp.dest(PROJECT_PATH.icons));
});
// #############################################################################
// 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('jshint', function () {
return gulp.src(PROJECT_PATTERNS.lint)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
// #############################################################################
// JS UNIT-TESTS
gulp.task('tests:unit', function (done) {
new Server({
configFile: PROJECT_PATH.tests + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('tests:watch', function () {
gulp.watch(PROJECT_PATTERNS.lint, ['tests:unit']);
});
// #############################################################################
// TASKS
gulp.task('js', gulpsync.sync(['jshint', 'jscs', 'tests:unit']));
gulp.task('js:watch', function () {
gulp.watch(PROJECT_PATTERNS.lint, ['js']);
});
gulp.task('watch', ['sass:watch', 'js:watch']);
gulp.task('lint', ['jscs', 'jshint']);
gulp.task('lint:watch', function () {
gulp.watch(PROJECT_PATTERNS.lint, ['lint']);
});
gulp.task('ci', ['js']);
gulp.task('default', ['sass', 'sass:watch', 'js', 'js:watch']);