Passed
Push — master ( 864108...2006ab )
by Warwick
03:11
created

gulpfile.js (16 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
const gulp         = require('gulp');
2
const rtlcss       = require('gulp-rtlcss');
3
const sass         = require('gulp-sass');
4
const sourcemaps   = require('gulp-sourcemaps');
5
const jshint       = require('gulp-jshint');
6
const concat       = require('gulp-concat');
7
const uglify       = require('gulp-uglify');
8
const sort         = require('gulp-sort');
0 ignored issues
show
The constant sort seems to be never used. Consider removing it.
Loading history...
9
const gettext      = require('gulp-gettext');
0 ignored issues
show
The constant gettext seems to be never used. Consider removing it.
Loading history...
10
const plumber      = require('gulp-plumber');
11
const autoprefixer = require('gulp-autoprefixer');
12
const gutil        = require('gulp-util');
13
const rename       = require('gulp-rename');
14
const minify       = require('gulp-minify-css');
0 ignored issues
show
The constant minify seems to be never used. Consider removing it.
Loading history...
15
const map          = require('map-stream');
16
const browserlist  = ['last 2 version', '> 1%'];
17
18
const errorreporter = map(function(file, cb) {
0 ignored issues
show
The constant errorreporter seems to be never used. Consider removing it.
Loading history...
19
	if (file.jshint.success) {
20
		return cb(null, file);
21
	}
22
23
	console.log('JSHINT fail in', file.path);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
24
25
	file.jshint.results.forEach(function (result) {
26
		if (!result.error) {
27
			return;
28
		}
29
30
		const err = result.error
31
		console.log(`  line ${err.line}, col ${err.character}, code ${err.code}, ${err.reason}`);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
32
	});
33
34
	cb(null, file);
0 ignored issues
show
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
35
});
36
37
gulp.task('default', function() {
38
	console.log('Use the following commands');
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
39
	console.log('--------------------------');
40
	console.log('gulp compile-css    to compile the scss to css');
41
	console.log('gulp compile-js     to compile the js to min.js');
42
	console.log('gulp watch          to continue watching the files for changes');
43
	console.log('gulp wordpress-lang to compile the lsx.pot, en_EN.po and en_EN.mo');
44
});
45
46
gulp.task('styles', function () {
47
	return gulp.src('assets/css/scss/*.scss')
48
		.pipe(plumber({
49
			errorHandler: function(err) {
50
				console.log(err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
51
				this.emit('end');
52
			}
53
		}))
54
		.pipe(sourcemaps.init())
55
		.pipe(sass({
56
			outputStyle: 'compact',
57
			includePaths: ['assets/css/scss']
58
		}).on('error', gutil.log))
59
		.pipe(autoprefixer({
60
			browsers: browserlist,
61
			casacade: true
62
		}))
63
		.pipe(sourcemaps.write('maps'))
64
		.pipe(gulp.dest('assets/css'))
65
});
66
67
gulp.task('styles-rtl', function () {
68
	return gulp.src('assets/css/scss/*.scss')
69
		.pipe(plumber({
70
			errorHandler: function(err) {
71
				console.log(err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
72
				this.emit('end');
73
			}
74
		}))
75
		.pipe(sass({
76
			outputStyle: 'compact',
77
			includePaths: ['assets/css/scss']
78
		}).on('error', gutil.log))
79
		.pipe(autoprefixer({
80
			browsers: browserlist,
81
			casacade: true
82
		}))
83
		.pipe(rtlcss())
84
		.pipe(rename({
85
			suffix: '-rtl'
86
		}))
87
		.pipe(gulp.dest('assets/css'))
88
});
89
90
gulp.task('vendor-styles', function () {
91
	return gulp.src('assets/css/vendor/*.scss')
92
		.pipe(plumber({
93
			errorHandler: function(err) {
94
				console.log(err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
95
				this.emit('end');
96
			}
97
		}))
98
		.pipe(sass({
99
			outputStyle: 'compact',
100
			includePaths: ['assets/css/vendor']
101
		}).on('error', gutil.log))
102
		.pipe(autoprefixer({
103
			browsers: browserlist,
104
			casacade: true
105
		}))
106
		.pipe(gulp.dest('assets/css/vendor'))
107
});
108
109
gulp.task('vendor-styles-rtl', function () {
110
	return gulp.src('assets/css/vendor/*.scss')
111
		.pipe(plumber({
112
			errorHandler: function(err) {
113
				console.log(err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
114
				this.emit('end');
115
			}
116
		}))
117
		.pipe(sass({
118
			outputStyle: 'compact',
119
			includePaths: ['assets/css/vendor']
120
		}).on('error', gutil.log))
121
		.pipe(autoprefixer({
122
			browsers: browserlist,
123
			casacade: true
124
		}))
125
		.pipe(rtlcss())
126
		.pipe(rename({
127
			suffix: '-rtl'
128
		}))
129
		.pipe(gulp.dest('assets/css/vendor'))
130
});
131
132
gulp.task('admin-styles', function () {
133
	return gulp.src('assets/css/admin/*.scss')
134
		.pipe(plumber({
135
			errorHandler: function(err) {
136
				console.log(err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
137
				this.emit('end');
138
			}
139
		}))
140
		.pipe(sourcemaps.init())
141
		.pipe(sass({
142
			outputStyle: 'compact',
143
			includePaths: ['assets/css/admin']
144
		}).on('error', gutil.log))
145
		.pipe(autoprefixer({
146
			browsers: browserlist,
147
			casacade: true
148
		}))
149
		.pipe(sourcemaps.write('maps'))
150
		.pipe(gulp.dest('assets/css/admin'))
151
});
152
153
gulp.task('admin-styles-rtl', function () {
154
	return gulp.src('assets/css/admin/*.scss')
155
		.pipe(plumber({
156
			errorHandler: function(err) {
157
				console.log(err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
158
				this.emit('end');
159
			}
160
		}))
161
		.pipe(sass({
162
			outputStyle: 'compact',
163
			includePaths: ['assets/css/admin']
164
		}).on('error', gutil.log))
165
		.pipe(autoprefixer({
166
			browsers: browserlist,
167
			casacade: true
168
		}))
169
		.pipe(rtlcss())
170
		.pipe(rename({
171
			suffix: '-rtl'
172
		}))
173
		.pipe(gulp.dest('assets/css/admin'))
174
});
175
176
//gulp.task('compile-css', ['styles', 'styles-rtl', 'vendor-styles', 'vendor-styles-rtl', 'admin-styles', 'admin-styles-rtl']);
177
178
gulp.task('compile-css', ['styles', 'styles-rtl', 'vendor-styles', 'vendor-styles-rtl', 'admin-styles']);
179
180
gulp.task('js', function() {
181
	return gulp.src('assets/js/src/**/*.js')
182
		.pipe(plumber({
183
			errorHandler: function(err) {
184
				console.log(err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
185
				this.emit('end');
186
			}
187
		}))
188
		.pipe(jshint())
189
		//.pipe(errorreporter)
190
		.pipe(concat('lsx.min.js'))
191
		.pipe(uglify())
192
		.pipe(gulp.dest('assets/js'))
193
});
194
195
gulp.task('vendor-bootstrap-js', function() {
196
	return gulp.src('assets/js/vendor/bootstrap.js')
197
		.pipe(plumber({
198
			errorHandler: function(err) {
199
				console.log(err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
200
				this.emit('end');
201
			}
202
		}))
203
		.pipe(jshint())
204
		//.pipe(errorreporter)
205
		.pipe(concat('bootstrap.min.js'))
206
		.pipe(uglify())
207
		.pipe(gulp.dest('assets/js/vendor'))
208
});
209
210
gulp.task('compile-js', ['js', 'vendor-bootstrap-js']);
211
212
gulp.task('watch-css', function () {
213
	return gulp.watch('assets/css/**/*.scss', ['compile-css']);
214
});
215
216
gulp.task('watch-js', function () {
217
	return gulp.watch('assets/js/src/**/*.js', ['compile-js']);
218
});
219
220
gulp.task('watch', ['watch-css', 'watch-js']);
221