From 0c3ba8c0dbd96ca4ba52f7531b2de1e38d29e150 Mon Sep 17 00:00:00 2001 From: Josh Thomas Date: Tue, 12 Apr 2016 20:27:48 -0500 Subject: [PATCH] Added publish.nightly task to gulp file. --- gulpfile.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/gulpfile.js b/gulpfile.js index a5c4e75a8ac..5bd20cb8bdc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -843,6 +843,50 @@ gulp.task('publish.npm', function(done) { }); }); + +/** + * Publishes a new tag to npm with a nightly tag. + */ +gulp.task('publish.nightly', function(done) { + var fs = require('fs'); + var spawn = require('child_process').spawn; + var packageJSON = require('./package.json'); + var hashLength = 8; + + // Generate a unique hash based on current timestamp + function createUniqueHash() { + var makeHash = require('crypto').createHash('sha1'); + var timeString = (new Date).getTime().toString(); + return makeHash.update(timeString).digest('hex').substring(0, hashLength); + } + + /** + * Split the version on dash so that we can add nightly + * to all production, beta, and nightly releases + * 0.1.0 -becomes- 0.1.0-r8e7684t + * 0.1.0-beta.0 -becomes- 0.1.0-beta.0-r8e7684t + * 0.1.0-beta.0-t5678e3v -becomes- 0.1.0-beta.0-r8e7684t + */ + packageJSON.version = packageJSON.version.split('-') + .slice(0, 2) + .concat(createUniqueHash()) + .join('-'); + + var npmCmd = spawn('npm', ['publish', '--tag=nightly', './dist']); + + npmCmd.stdout.on('data', function (data) { + console.log(data.toString()); + }); + + npmCmd.stderr.on('data', function (data) { + console.log('npm err: ' + data.toString()); + }); + + npmCmd.on('close', function() { + done(); + }); +}); + /** * Build Ionic sources, with typechecking, .d.ts definition generation and debug * statements removed.