Skip to content

Commit

Permalink
Add task for automatic version injection
Browse files Browse the repository at this point in the history
  • Loading branch information
feimosi committed Feb 2, 2016
1 parent 7a9d8f4 commit 4b88900
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
30 changes: 27 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')(),
browserSync = require('browser-sync');
browserSync = require('browser-sync'),
runSequence = require('run-sequence');

var src = {
css: ['./src/*.scss', './src/*.css'],
js: './src/*.js'
Expand Down Expand Up @@ -81,6 +83,22 @@ gulp.task('bump-patch', function () {
.pipe(gulp.dest('./'));
});

// Update version number in project files
gulp.task('update-version', function () {
return gulp.src([build.css + '*.css',
build.js + '*.js',
dist.css + '*.css',
dist.js + '*.js'
], {
base: './'
})
.pipe(plugins.injectVersion({
replace: '%%INJECT_VERSION%%',
prepend: { toString: function() { return ''; } }
}))
.pipe(gulp.dest('./'));
});

// Watch files for changes
gulp.task('watch', ['browser-sync'], function() {
// Watch Sass files
Expand All @@ -107,6 +125,12 @@ gulp.task('browser-sync', ['js', 'css'], function () {
// Default task
gulp.task('default', ['css', 'js', 'watch', 'browser-sync']);

gulp.task('release', ['css-min', 'js-min', 'bump-minor']);
gulp.task('release', function() {
runSequence('bump-minor', 'build', 'update-version');
});

gulp.task('patch', function() {
runSequence('bump-patch', 'build', 'update-version');
});

gulp.task('patch', ['css-min', 'js-min', 'bump-patch']);
gulp.task('build', ['css', 'js', 'css-min', 'js-min']);
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
"gulp-concat": "~2.6.0",
"gulp-cssmin": "~0.1.7",
"gulp-if": "~2.0.0",
"gulp-inject-version": "~1.0.0",
"gulp-jshint": "~1.11.2",
"gulp-load-plugins": "1.0.0-rc.1",
"gulp-rimraf": "~0.2.0",
"gulp-sass": "~2.0.4",
"gulp-uglify": "~1.4.1",
"gulp-usemin": "~0.3.14",
"jshint-stylish": "~2.0.1"
"jshint-stylish": "~2.0.1",
"run-sequence": "~1.1.5"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion src/baguetteBox.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* baguetteBox.js
* @author feimosi
* @version 1.4.2
* @version %%INJECT_VERSION%%
* @url https://github.com/feimosi/baguetteBox.js
*/

Expand Down
2 changes: 1 addition & 1 deletion src/baguetteBox.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* baguetteBox.js
* @author feimosi
* @version 1.4.2
* @version %%INJECT_VERSION%%
* @url https://github.com/feimosi/baguetteBox.js
*/

Expand Down

0 comments on commit 4b88900

Please sign in to comment.