chore(build): add version task

This commit is contained in:
Andy Joslin
2014-02-05 14:19:24 -05:00
parent b868584a18
commit 7039ea42ab
2 changed files with 23 additions and 4 deletions

View File

@@ -19,6 +19,12 @@ module.exports = function(grunt) {
}
},
version: {
dist: {
dest: 'dist/version.json'
}
},
copy: {
dist: {
files: [{
@@ -150,7 +156,8 @@ module.exports = function(grunt) {
'concat',
'copy',
'uglify',
'string-replace'
'string-replace',
'version'
]);
grunt.registerMultiTask('karma', 'Run karma', function() {
@@ -171,4 +178,19 @@ module.exports = function(grunt) {
done();
});
});
grunt.registerMultiTask('version', 'Generate version JSON', function() {
var pkg = grunt.config('pkg');
this.files.forEach(function(file) {
var dest = file.dest;
var d = new Date();
var version = {
version: pkg.version,
codename: pkg.codename,
date: grunt.template.today('yyyy-mm-dd'),
time: d.getUTCHours() + ':' + d.getUTCMinutes() + ':' + d.getUTCSeconds()
};
grunt.file.write(dest, JSON.stringify(version, null, 2));
});
});
};

View File

@@ -33,9 +33,6 @@ function run {
cd $VERSION_DIR
cp -R $BUILD_DIR/* $VERSION_DIR
# Create a version.txt file with the version and codename
echo "$VERSION $CODENAME" > version.txt
echo "-- Generating versions.json..."
cd $IONIC_CODE_DIR/builder
python ./generate.py > /dev/null