Skip to content

Commit

Permalink
Merge pull request #6146 from driftyco/gulp-build-nightly
Browse files Browse the repository at this point in the history
chore(build): add publish.nightly task to gulp file
  • Loading branch information
adamdbradley committed Apr 13, 2016
2 parents 4978253 + 0c3ba8c commit c594c43
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c594c43

Please sign in to comment.