pryley /
pollux
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | var args = require('yargs').argv; |
||
| 2 | var autoprefixer = require('gulp-autoprefixer'); |
||
| 3 | var babel = require('gulp-babel'); |
||
| 4 | var bump = require('gulp-bump'); |
||
| 5 | var checktextdomain = require('gulp-checktextdomain'); |
||
| 6 | var cssnano = require('gulp-cssnano'); |
||
| 7 | var gulp = require('gulp'); |
||
| 8 | var gulpif = require('gulp-if'); |
||
| 9 | var jshint = require('gulp-jshint'); |
||
| 10 | var plumber = require('gulp-plumber'); |
||
| 11 | var potomo = require('gulp-potomo'); |
||
| 12 | var pseudo = require('gulp-pseudo-i18n'); |
||
| 13 | var rename = require('gulp-rename'); |
||
| 14 | var runSequence = require('run-sequence'); |
||
| 15 | var sass = require('gulp-sass'); |
||
| 16 | var sort = require('gulp-sort'); |
||
| 17 | var uglify = require('gulp-uglify'); |
||
| 18 | var wpPot = require('gulp-wp-pot'); |
||
| 19 | var yaml = require('yamljs'); |
||
| 20 | |||
| 21 | var config = yaml.load('+/config.yml'); |
||
| 22 | |||
| 23 | /* JSHint Task |
||
| 24 | -------------------------------------------------- */ |
||
| 25 | gulp.task('jshint', function() { |
||
| 26 | return gulp.src(config.watch.js) |
||
| 27 | .pipe(plumber({ |
||
| 28 | errorHandler: function(error) { |
||
| 29 | console.log(error.message); |
||
|
1 ignored issue
–
show
Debugging Code
introduced
by
Loading history...
|
|||
| 30 | this.emit('end'); |
||
| 31 | }})) |
||
| 32 | .pipe(jshint()) |
||
| 33 | .pipe(jshint.reporter('jshint-stylish')) |
||
| 34 | }); |
||
| 35 | |||
| 36 | /* JS Task |
||
| 37 | -------------------------------------------------- */ |
||
| 38 | gulp.task('js', function() { |
||
| 39 | return gulp.src(config.watch.js) |
||
| 40 | .pipe(plumber({ |
||
| 41 | errorHandler: function(error) { |
||
| 42 | console.log(error.message); |
||
|
1 ignored issue
–
show
|
|||
| 43 | this.emit('end'); |
||
| 44 | }})) |
||
| 45 | .pipe(babel({ |
||
| 46 | presets: ["env"] |
||
| 47 | })) |
||
| 48 | .pipe(gulpif(args.production, uglify({ |
||
| 49 | preserveComments: 'license', |
||
| 50 | }))) |
||
| 51 | .pipe(gulp.dest(config.dest.js)) |
||
| 52 | }); |
||
| 53 | |||
| 54 | /* CSS Task |
||
| 55 | -------------------------------------------------- */ |
||
| 56 | gulp.task('css', function() { |
||
| 57 | return gulp.src(config.watch.scss) |
||
| 58 | .pipe(plumber({ |
||
| 59 | errorHandler: function(error) { |
||
| 60 | console.log(error.message); |
||
|
1 ignored issue
–
show
|
|||
| 61 | this.emit('end'); |
||
| 62 | }})) |
||
| 63 | .pipe(sass({ |
||
| 64 | outputStyle: 'expanded', |
||
| 65 | })) |
||
| 66 | .pipe(autoprefixer('last 2 versions')) |
||
| 67 | .pipe(gulpif(args.production, cssnano({ |
||
| 68 | minifyFontValues: false, |
||
| 69 | discardComments: { removeAll: true } |
||
| 70 | }))) |
||
| 71 | .pipe(gulp.dest(config.dest.css)) |
||
| 72 | }); |
||
| 73 | |||
| 74 | /* Language Tasks |
||
| 75 | -------------------------------------------------- */ |
||
| 76 | gulp.task('languages', function() { |
||
| 77 | return runSequence('po', 'mo') |
||
| 78 | }); |
||
| 79 | |||
| 80 | gulp.task('po', function() { |
||
| 81 | return gulp.src(config.watch.php) |
||
| 82 | .pipe(checktextdomain({ |
||
| 83 | text_domain: config.language.domain, |
||
| 84 | keywords: [ |
||
| 85 | '__:1,2d', |
||
| 86 | '_e:1,2d', |
||
| 87 | '_x:1,2c,3d', |
||
| 88 | 'esc_html__:1,2d', |
||
| 89 | 'esc_html_e:1,2d', |
||
| 90 | 'esc_html_x:1,2c,3d', |
||
| 91 | 'esc_attr__:1,2d', |
||
| 92 | 'esc_attr_e:1,2d', |
||
| 93 | 'esc_attr_x:1,2c,3d', |
||
| 94 | '_ex:1,2c,3d', |
||
| 95 | '_n:1,2,4d', |
||
| 96 | '_nx:1,2,4c,5d', |
||
| 97 | '_n_noop:1,2,3d', |
||
| 98 | '_nx_noop:1,2,3c,4d', |
||
| 99 | ], |
||
| 100 | })) |
||
| 101 | .pipe(sort()) |
||
| 102 | .pipe(wpPot({ |
||
| 103 | domain: config.language.domain, |
||
| 104 | lastTranslator: config.language.translator, |
||
| 105 | team: config.language.team, |
||
| 106 | })) |
||
| 107 | .pipe(pseudo({ |
||
| 108 | // language: 'en_US', |
||
| 109 | charMap: {}, |
||
| 110 | })) |
||
| 111 | .pipe(rename(config.language.domain + '-en_US.po')) |
||
| 112 | .pipe(gulp.dest(config.dest.lang)); |
||
| 113 | }); |
||
| 114 | |||
| 115 | gulp.task('mo', function() { |
||
| 116 | return gulp.src(config.dest.lang + '*.po') |
||
| 117 | .pipe(potomo()) |
||
| 118 | .pipe(gulp.dest(config.dest.lang)); |
||
| 119 | }); |
||
| 120 | |||
| 121 | /* Version Task |
||
| 122 | -------------------------------------------------- */ |
||
| 123 | gulp.task('bump', function() { |
||
| 124 | return gulp.src(config.primary_file) |
||
| 125 | .pipe(gulpif(args.patch || Object.keys(args).length < 3, bump({ |
||
| 126 | type: 'patch' |
||
| 127 | }))) |
||
| 128 | .pipe(gulpif(args.minor, bump({ |
||
| 129 | type: 'minor' |
||
| 130 | }))) |
||
| 131 | .pipe(gulpif(args.major, bump({ |
||
| 132 | type: 'major' |
||
| 133 | }))) |
||
| 134 | .pipe(gulp.dest('.')) |
||
| 135 | }); |
||
| 136 | |||
| 137 | /* Watch Task |
||
| 138 | -------------------------------------------------- */ |
||
| 139 | gulp.task('watch', function() { |
||
| 140 | gulp.watch(config.watch.js, ['jshint', 'js']); |
||
| 141 | gulp.watch(config.watch.scss, ['css']); |
||
| 142 | }); |
||
| 143 | |||
| 144 | /* Default Task |
||
| 145 | -------------------------------------------------- */ |
||
| 146 | gulp.task('default', function() { |
||
| 147 | gulp.start('css', 'jshint', 'js') |
||
| 148 | }); |
||
| 149 | |||
| 150 | /* Build Task |
||
| 151 | -------------------------------------------------- */ |
||
| 152 | gulp.task('build', function() { |
||
| 153 | gulp.start('css', 'jshint', 'js', 'languages') |
||
| 154 | }); |
||
| 155 |