diff --git a/Gruntfile.js b/Gruntfile.js index d7a24c0b..4aec8619 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,4 @@ module.exports = function(grunt) { - 'use strict'; var version = grunt.option('release'); @@ -182,7 +181,7 @@ module.exports = function(grunt) { } grunt.registerTask('default', 'Build OpenPGP.js', function() { - grunt.task.run(['clean', 'copy:zlib', 'browserify', 'replace', 'uglify']); + grunt.task.run(['clean', 'copy:zlib', 'browserify', 'replace', 'uglify', 'npm_pack']); //TODO jshint is not run because of too many discovered issues, once these are addressed it should autorun grunt.log.ok('Before Submitting a Pull Request please also run `grunt jshint`.'); }); @@ -199,6 +198,25 @@ module.exports = function(grunt) { mocha.stderr.pipe(process.stderr); }); + // Alias the `npm_pack` task to run `npm pack` + grunt.registerTask('npm_pack', 'npm pack', function () { + var done = this.async(); + var npm = require('child_process').exec('npm pack ../', { cwd: 'dist'}, function (err, stdout) { + var package = stdout; + if (err === null) { + var install = require('child_process').exec('npm install dist/' + package, function (err) { + done(err); + }); + install.stdout.pipe(process.stdout); + install.stderr.pipe(process.stderr); + } else { + done(err); + } + }); + npm.stdout.pipe(process.stdout); + npm.stderr.pipe(process.stderr); + }); + // Test/Dev tasks grunt.registerTask('test', ['copy:npm', 'mochaTest', 'mocha_phantomjs']); }; diff --git a/release.sh b/release.sh index a0a2c171..7a82931b 100755 --- a/release.sh +++ b/release.sh @@ -22,7 +22,7 @@ grunt set_version --release=$1 npm test # Add build files to git -sed -i "" '/dist/d' .gitignore +sed -i "" '/^dist\/$/d' .gitignore git add dist/ *.json git commit -m "Release new version" git checkout .gitignore