Skip to content

Instantly share code, notes, and snippets.

@intellix
Created February 9, 2015 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intellix/aa9fa4d9a1871f8b6d04 to your computer and use it in GitHub Desktop.
Save intellix/aa9fa4d9a1871f8b6d04 to your computer and use it in GitHub Desktop.
gulp deploy task for creating a number incremented folder for symlinking to
/**
* For creating a numbered folder inside /deploys,
* shoving in the contents of /dist and for symlinking to when happy. Eg:
* /deploys/2
* /www --> symlinks to --> /deploys/2
*/
gulp.task('deploy', function (cb) {
var deploys = fs.readdirSync('./deploys');
var version = 1;
if (deploys.length) {
version = parseInt(_.max(deploys, function(num) {
var numb = parseInt(num, 10);
if (!isNaN(numb)) {
return numb;
}
}), 10) + 1 || 1;
}
gutil.log(gutil.colors.cyan('Deploying: v' + version));
return gulp.src('dist/**/*')
.pipe(gulp.dest('deploys/' + version));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment