Passed
Branch master (57a609)
by Chris
07:41
created

gulpfile.js   A

Complexity

Total Complexity 16
Complexity/F 1

Size

Lines of Code 146
Function Count 16

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 16
eloc 107
mnd 0
bc 0
fnc 16
dl 0
loc 146
rs 10
bpm 0
cpm 1
noi 10
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-health-plan.pot, lsx-health-plan-en_EN.po and lsx-health-plan-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
	done();
74
}));
75
76
gulp.task('js', function(done) {
77
	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...
78
		.pipe(plumber({
79
			errorHandler: function(err) {
80
				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...
81
				this.emit('end');
82
			}
83
		}))
84
		.pipe(jshint())
85
		.pipe(uglify())
86
		.pipe(rename({
87
			suffix: '.min'
88
		}))
89
		.pipe(gulp.dest('assets/js')),
90
		done();
91
});
92
93
gulp.task('compile-js', gulp.series( ['js'] , function(done) {
94
	done();
95
}));
96
97
gulp.task('watch-css', function (done) {
98
	done();
99
	return gulp.watch('assets/css/**/*.scss', gulp.series('compile-css'));
100
});
101
102
gulp.task('watch-js', function (done) {
103
	done();
104
	return gulp.watch('assets/js/src/**/*.js', gulp.series('compile-js'));
105
});
106
107
gulp.task('watch', gulp.series( ['watch-css', 'watch-js'] , function(done) {
108
	done();
109
}));
110
111
gulp.task('wordpress-pot', function(done) {
112
	return gulp.src('**/*.php')
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...
113
		.pipe(sort())
114
		.pipe(wppot({
115
			domain: 'lsx-health-plan',
116
			package: 'lsx-health-plan',
117
			bugReport: 'https://github.com/lightspeeddevelopment/lsx-health-plan/issues',
118
			team: 'LightSpeed <[email protected]>'
119
		}))
120
		.pipe(gulp.dest('languages/lsx-health-plan.pot')),
121
		done();
122
});
123
124
gulp.task('wordpress-po', function(done) {
125
	return gulp.src('**/*.php')
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...
126
		.pipe(sort())
127
		.pipe(wppot({
128
			domain: 'lsx-health-plan',
129
			package: 'lsx-health-plan',
130
			bugReport: 'https://github.com/lightspeeddevelopment/lsx-health-plan/issues',
131
			team: 'LightSpeed <[email protected]>'
132
		}))
133
		.pipe(gulp.dest('languages/lsx-health-plan-en_EN.po')),
134
		done();
135
});
136
137
gulp.task('wordpress-po-mo', gulp.series( ['wordpress-po'], function(done) {
138
	return gulp.src('languages/lsx-health-plan-en_EN.po')
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...
139
		.pipe(gettext())
140
		.pipe(gulp.dest('languages')),
141
		done();
142
}));
143
144
gulp.task('wordpress-lang', gulp.series( ['wordpress-pot', 'wordpress-po-mo'] , function(done) {
145
	done();
146
}));
147