Fix releasing not reloading pkg, thus breaking on build-crx.

This commit is contained in:
Nicolas Stepien 2013-04-14 19:03:31 +02:00
parent 1ec6be21a2
commit f753ed1db6

View File

@ -1,13 +1,18 @@
module.exports = function(grunt) { module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json'); var pkg = grunt.file.readJSON('package.json');
var concatOptions = {
process: {
data: pkg
}
};
// Project configuration. // Project configuration.
grunt.initConfig({ grunt.initConfig({
pkg: pkg, pkg: pkg,
concat: { concat: {
coffee: { coffee: {
options: { process: { data: pkg } }, options: concatOptions,
src: [ src: [
'src/config.coffee', 'src/config.coffee',
'src/globals.coffee', 'src/globals.coffee',
@ -23,7 +28,7 @@ module.exports = function(grunt) {
dest: 'tmp/script.coffee' dest: 'tmp/script.coffee'
}, },
crx: { crx: {
options: { process: { data: pkg } }, options: concatOptions,
files: { files: {
'builds/crx/manifest.json': 'src/manifest.json', 'builds/crx/manifest.json': 'src/manifest.json',
'builds/crx/script.js': [ 'builds/crx/script.js': [
@ -33,7 +38,7 @@ module.exports = function(grunt) {
} }
}, },
userjs: { userjs: {
options: { process: { data: pkg } }, options: concatOptions,
src: [ src: [
'src/metadata.js', 'src/metadata.js',
'src/banner.js', 'src/banner.js',
@ -42,7 +47,7 @@ module.exports = function(grunt) {
dest: 'builds/<%= pkg.name %>.js' dest: 'builds/<%= pkg.name %>.js'
}, },
userscript: { userscript: {
options: { process: { data: pkg } }, options: concatOptions,
files: { files: {
'builds/<%= pkg.name %>.meta.js': 'src/metadata.js', 'builds/<%= pkg.name %>.meta.js': 'src/metadata.js',
'builds/<%= pkg.name %>.user.js': [ 'builds/<%= pkg.name %>.user.js': [
@ -160,12 +165,18 @@ module.exports = function(grunt) {
]); ]);
grunt.registerTask('release', ['exec:commit', 'exec:push', 'build-crx', 'compress:crx']); grunt.registerTask('release', ['exec:commit', 'exec:push', 'build-crx', 'compress:crx']);
grunt.registerTask('patch', ['bump', 'updcl:3', 'release']); grunt.registerTask('patch', ['bump', 'reloadPkg', 'updcl:3', 'release']);
grunt.registerTask('minor', ['bump:minor', 'updcl:2', 'release']); grunt.registerTask('minor', ['bump:minor', 'reloadPkg', 'updcl:2', 'release']);
grunt.registerTask('major', ['bump:major', 'updcl:1', 'release']); grunt.registerTask('major', ['bump:major', 'reloadPkg', 'updcl:1', 'release']);
grunt.registerTask('updcl', 'Update the changelog', function(i) {
grunt.registerTask('reloadPkg', 'Reload the package', function() {
// Update the `pkg` object with the new version. // Update the `pkg` object with the new version.
pkg = grunt.file.readJSON('package.json'); pkg = grunt.file.readJSON('package.json');
concatOptions.process.data = pkg;
grunt.log.ok('pkg reloaded.');
});
grunt.registerTask('updcl', 'Update the changelog', function(i) {
// i is the number of #s for markdown. // i is the number of #s for markdown.
var version = new Array(+i + 1).join('#') + ' ' + pkg.version + ' - *' + grunt.template.today('yyyy-mm-dd') + '*'; var version = new Array(+i + 1).join('#') + ' ' + pkg.version + ' - *' + grunt.template.today('yyyy-mm-dd') + '*';
grunt.file.write('CHANGELOG.md', version + '\n\n' + grunt.file.read('CHANGELOG.md')); grunt.file.write('CHANGELOG.md', version + '\n\n' + grunt.file.read('CHANGELOG.md'));