aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2013-07-13 23:41:47 -0700
committerBrian Ford2013-08-12 16:23:38 -0700
commitedef295b116f10af733d33a7c2b30c7c741f7900 (patch)
tree7b104eb911bb904c5787efd496ad2ac7f5e14ff4
parent64e447354e48da2bc93a4e95d5dd62b69f6a1325 (diff)
downloadangular.js-edef295b116f10af733d33a7c2b30c7c741f7900.tar.bz2
fix(grunt): cache version number
caching the version number speeds up the build and preserves resources. this also fixed EMFILE error that now occurs on some macs.
-rw-r--r--lib/grunt/utils.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/grunt/utils.js b/lib/grunt/utils.js
index f0fffb14..ea8c65d5 100644
--- a/lib/grunt/utils.js
+++ b/lib/grunt/utils.js
@@ -2,6 +2,7 @@ var fs = require('fs');
var shell = require('shelljs');
var grunt = require('grunt');
var spawn = require('child_process').spawn;
+var version;
module.exports = {
@@ -11,13 +12,18 @@ module.exports = {
getVersion: function(){
+ if (version) return version;
+
var package = JSON.parse(fs.readFileSync('package.json', 'UTF-8'));
var match = package.version.match(/^([^\-]*)(-snapshot)?$/);
var semver = match[1].split('.');
var hash = shell.exec('git rev-parse --short HEAD', {silent: true}).output.replace('\n', '');
- var version = {
- full: (match[1] + (match[2] ? '-' + hash : '')),
+ var fullVersion = (match[1] + (match[2] ? '-' + hash : ''));
+ var numVersion = semver[0] + '.' + semver[1] + '.' + semver[2];
+ version = {
+ number: numVersion,
+ full: fullVersion,
major: semver[0],
minor: semver[1],
dot: semver[2],