Created
October 21, 2014 15:35
-
-
Save mackensen/98324e6b5d7d34eccaf5 to your computer and use it in GitHub Desktop.
Revisions
-
mackensen created this gist
Oct 21, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,76 @@ // List of modules used. var gulp = require('gulp'), bump = require('gulp-bump'), // Generates new version. argv = require('yargs') .default('release', 'patch') .argv, // CLI parser. fs = require('fs'), // Used by bump. semver = require('semver'), // Used by bump. git = require('gulp-git'), // Git wrapper. jshint = require('gulp-jshint'), // Lints JS. phplint = require('phplint'), // Lints PHP. replace = require('gulp-replace'); // Text replacer. // Parses the package.json file. We use this because its values // change during execution. var getPackageJSON = function() { return JSON.parse(fs.readFileSync('./package.json', 'utf8')); }; // Lint associated PHP files. gulp.task('phplint', function() { return phplint(['*.php', './functions/**/*.php']); }); // Lint associated Javascripts. gulp.task('scripts', function() { gulp.src('./gulpfile.js') .pipe(jshint()) .pipe(jshint.reporter('default')) .pipe(gulp.dest('./')); gulp.src('./javascripts/global.js') .pipe(jshint()) .pipe(jshint.reporter('default')) .pipe(gulp.dest('./javascripts')); }); // Integration task. Bumps version and commits. // Tagging is separate. gulp.task('integrate', function() { var pkg = getPackageJSON(); var newversion = semver.inc(pkg.version, argv.release); var banner = ['/*', 'Theme Name: ' + pkg.description, 'Theme URI: '+ pkg.uri, 'Author: '+ pkg.author, 'Version: '+ newversion, 'License: '+ pkg.license, 'License URI: '+ pkg.licenseuri, '*/', ''].join('\n'); gulp.src('./package.json') .pipe(bump({version: newversion})) .pipe(gulp.dest('./')); gulp.src(['./functions.php']) .pipe(replace(pkg.version, newversion)) .pipe(gulp.dest('./')); fs.writeFile('./style.css', banner); gulp.src(['package.json','style.css','functions.php']) .pipe(git.commit(pkg.description + ' v' + newversion, {cwd: './'})); }); // Tags. Run this after integrating. gulp.task('tag', function() { var pkg = getPackageJSON(); git.tag('v'+pkg.version, pkg.description + ' v' + pkg.version, function(err) { }); }); // Watch tasks. gulp.task('watch', function() { gulp.watch(['*.php', './functions/**/*.php'],['phplint']); });