Passed
Branch master (5e3715)
by Chris
07:17
created

gulpfile.js   A

Complexity

Total Complexity 16
Complexity/F 1

Size

Lines of Code 150
Function Count 16

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 16
eloc 111
mnd 0
bc 0
fnc 16
dl 0
loc 150
rs 10
bpm 0
cpm 1
noi 11
c 0
b 0
f 0
1
const gulp         = require('gulp');
2
const autoprefixer = require('gulp-autoprefixer');
3
const gettext      = require('gulp-gettext');
4
const jshint       = require('gulp-jshint');
5
const plumber      = require('gulp-plumber');
6
const rename       = require('gulp-rename');
7
const rtlcss       = require('gulp-rtlcss');
8
const sass         = require('gulp-sass');
9
const sort         = require('gulp-sort');
10
const sourcemaps   = require('gulp-sourcemaps');
11
const uglify       = require('gulp-uglify');
12
const gutil        = require('gulp-util');
13
const wppot        = require('gulp-wp-pot');
14
15
const browserlist  = ['last 2 version', '> 1%'];
16
17
gulp.task('default', function() {
18
	console.log('Use the following commands');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
19
	console.log('--------------------------');
20
	console.log('gulp compile-css               to compile the scss to css');
21
	console.log('gulp compile-js                to compile the js to min.js');
22
	console.log('gulp watch                     to continue watching the files for changes');
23
	console.log('gulp wordpress-lang            to compile the lsx-search.pot, lsx-search-en_EN.po and lsx-search-en_EN.mo');
24
});
25
26
gulp.task('styles', function (done) {
27
	return gulp.src('assets/css/scss/*.scss')
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
28
		.pipe(plumber({
29
			errorHandler: function(err) {
30
				console.log(err);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
31
				this.emit('end');
32
			}
33
		}))
34
		.pipe(sourcemaps.init())
35
		.pipe(sass({
36
			outputStyle: 'compact',
37
			includePaths: ['assets/css/scss']
38
		}).on('error', gutil.log))
39
		.pipe(autoprefixer({
40
			browsers: browserlist,
41
			casacade: true
42
		}))
43
		.pipe(sourcemaps.write('maps'))
44
		.pipe(gulp.dest('assets/css')),
45
		done();
46
});
47
48
gulp.task('styles-rtl', function (done) {
49
	return gulp.src('assets/css/scss/*.scss')
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
50
		.pipe(plumber({
51
			errorHandler: function(err) {
52
				console.log(err);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
53
				this.emit('end');
54
			}
55
		}))
56
		.pipe(sass({
57
			outputStyle: 'compact',
58
			includePaths: ['assets/css/scss']
59
		}).on('error', gutil.log))
60
		.pipe(autoprefixer({
61
			browsers: browserlist,
62
			casacade: true
63
		}))
64
		.pipe(rtlcss())
65
		.pipe(rename({
66
			suffix: '-rtl'
67
		}))
68
		.pipe(gulp.dest('assets/css')),
69
		done();
70
});
71
72
gulp.task('compile-css', gulp.series( ['styles', 'styles-rtl'], function(done) {
73
	console.log('Done');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
74
	done();
75
}));
76
77
gulp.task('js', function(done) {
78
	return gulp.src('assets/js/src/**/*.js')
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
79
		.pipe(plumber({
80
			errorHandler: function(err) {
81
				console.log(err);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
82
				this.emit('end');
83
			}
84
		}))
85
		.pipe(jshint())
86
		.pipe(uglify())
87
		.pipe(rename({
88
			suffix: '.min'
89
		}))
90
		.pipe(gulp.dest('assets/js')),
91
		done();
92
});
93
94
gulp.task('compile-js', gulp.series( ['js'] , function(done) {
95
	console.log('Done');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
96
	done();
97
}));
98
99
gulp.task('watch-css', function (done) {
100
	done();
101
	return gulp.watch('assets/css/**/*.scss', gulp.series('compile-css'));
102
});
103
104
gulp.task('watch-js', function (done) {
105
	done();
106
	return gulp.watch('assets/js/src/**/*.js', gulp.series('compile-js'));
107
});
108
109
gulp.task('watch', gulp.series( ['watch-css', 'watch-js'] , function(done) {
110
	console.log('Done');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
111
	done();
112
}));
113
114
gulp.task('wordpress-pot', function(done) {
115
	done();
116
	return gulp.src('**/*.php')
117
		.pipe(sort())
118
		.pipe(wppot({
119
			domain: 'lsx-search',
120
			package: 'lsx-search',
121
			bugReport: 'https://github.com/lightspeeddevelopment/lsx-search/issues',
122
			team: 'LightSpeed <[email protected]>'
123
		}))
124
		.pipe(gulp.dest('languages/lsx-search.pot'))
125
});
126
127
gulp.task('wordpress-po', function(done) {
128
	done();
129
	return gulp.src('**/*.php')
130
		.pipe(sort())
131
		.pipe(wppot({
132
			domain: 'lsx-search',
133
			package: 'lsx-search',
134
			bugReport: 'https://github.com/lightspeeddevelopment/lsx-search/issues',
135
			team: 'LightSpeed <[email protected]>'
136
		}))
137
		.pipe(gulp.dest('languages/lsx-search-en_EN.po'))
138
});
139
140
gulp.task('wordpress-po-mo', gulp.series( ['wordpress-po'], function(done) {
141
	done();
142
	return gulp.src('languages/lsx-search-en_EN.po')
143
		.pipe(gettext())
144
		.pipe(gulp.dest('languages'))
145
}));
146
147
gulp.task('wordpress-lang', gulp.series( ['wordpress-pot', 'wordpress-po-mo'] , function(done) {
148
	console.log('Done');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
149
	done();
150
}));
151