Completed
Push — master ( a84d89...a9842c )
by Fernando
02:35
created

gulpfile.js ➔ map   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 2
nc 2
nop 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A gulpfile.js ➔ ... ➔ file.jshint.results.forEach 0 8 2
1
const gulp         = require('gulp');
2
const rtlcss       = require('gulp-rtlcss');
0 ignored issues
show
Unused Code introduced by
The constant rtlcss seems to be never used. Consider removing it.
Loading history...
3
const sass         = require('gulp-sass');
0 ignored issues
show
Unused Code introduced by
The constant sass seems to be never used. Consider removing it.
Loading history...
4
const sourcemaps   = require('gulp-sourcemaps');
0 ignored issues
show
Unused Code introduced by
The constant sourcemaps seems to be never used. Consider removing it.
Loading history...
5
const jshint       = require('gulp-jshint');
6
const concat       = require('gulp-concat');
7
const uglify       = require('gulp-uglify');
8
const sort         = require('gulp-sort');
9
const wppot        = require('gulp-wp-pot');
10
const gettext      = require('gulp-gettext');
11
const plumber      = require('gulp-plumber');
12
const autoprefixer = require('gulp-autoprefixer');
0 ignored issues
show
Unused Code introduced by
The constant autoprefixer seems to be never used. Consider removing it.
Loading history...
13
const gutil        = require('gulp-util');
0 ignored issues
show
Unused Code introduced by
The constant gutil seems to be never used. Consider removing it.
Loading history...
14
const rename       = require('gulp-rename');
0 ignored issues
show
Unused Code introduced by
The constant rename seems to be never used. Consider removing it.
Loading history...
15
const minify       = require('gulp-minify-css');
0 ignored issues
show
Unused Code introduced by
The constant minify seems to be never used. Consider removing it.
Loading history...
16
const map          = require('map-stream');
17
const browserlist  = ['last 2 version', '> 1%'];
0 ignored issues
show
Unused Code introduced by
The constant browserlist seems to be never used. Consider removing it.
Loading history...
18
19
const errorreporter = map(function(file, cb) {
0 ignored issues
show
Unused Code introduced by
The constant errorreporter seems to be never used. Consider removing it.
Loading history...
20
	if (file.jshint.success) {
21
		return cb(null, file);
22
	}
23
24
	console.log('JSHINT fail in', file.path);
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...
25
26
	file.jshint.results.forEach(function (result) {
27
		if (!result.error) {
28
			return;
29
		}
30
31
		const err = result.error
32
		console.log(`  line ${err.line}, col ${err.character}, code ${err.code}, ${err.reason}`);
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...
33
	});
34
35
	cb(null, file);
0 ignored issues
show
Best Practice introduced by
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...
36
});
37
38
gulp.task('default', function() {
39
	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...
40
	console.log('--------------------------');
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 wetu-importer.pot, en_EN.po and en_EN.mo');
44
});
45
46
gulp.task('js', function() {
47
	return gulp.src('assets/js/wetu-importer.js')
48
		.pipe(plumber({
49
			errorHandler: function(err) {
50
				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...
51
				this.emit('end');
52
			}
53
		}))
54
		.pipe(jshint())
55
		//.pipe(errorreporter)
56
		.pipe(concat('wetu-importer.min.js'))
57
		.pipe(uglify())
58
		.pipe(gulp.dest('assets/js'))
59
});
60
61
gulp.task('compile-js', ['js']);
62
63
gulp.task('watch-js', function () {
64
	return gulp.watch('assets/js/**/*.js', ['compile-js']);
65
});
66
67
gulp.task('watch', ['watch-css', 'watch-js']);
68
69
gulp.task('wordpress-pot', function() {
70
	return gulp.src('**/*.php')
71
		.pipe(sort())
72
		.pipe(wppot({
73
			domain: 'wetu-importer',
74
			package: 'wetu-importer',
75
			team: 'LightSpeed <[email protected]>'
76
		}))
77
		.pipe(gulp.dest('languages/wetu-importer.pot'))
78
});
79
80
gulp.task('wordpress-po', function() {
81
	return gulp.src('**/*.php')
82
		.pipe(sort())
83
		.pipe(wppot({
84
			domain: 'wetu-importer',
85
			package: 'wetu-importer',
86
			team: 'LightSpeed <[email protected]>'
87
		}))
88
		.pipe(gulp.dest('languages/en_EN.po'))
89
});
90
91
gulp.task('wordpress-po-mo', ['wordpress-po'], function() {
92
	return gulp.src('languages/en_EN.po')
93
		.pipe(gettext())
94
		.pipe(gulp.dest('languages'))
95
});
96
97
gulp.task('wordpress-lang', (['wordpress-pot', 'wordpress-po-mo']));
98