Added publish.nightly task to gulp file.

This commit is contained in:
Josh Thomas
2016-04-12 20:27:48 -05:00
parent dec9f76105
commit 0c3ba8c0db

View File

@ -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.