Created
February 9, 2015 10:48
-
-
Save intellix/aa9fa4d9a1871f8b6d04 to your computer and use it in GitHub Desktop.
gulp deploy task for creating a number incremented folder for symlinking to
This file contains 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 characters
/** | |
* 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