mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-06-17 02:41:49 +08:00
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.
This commit is contained in:
@@ -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,6 +12,8 @@ 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('.');
|
||||
@@ -18,7 +21,7 @@ module.exports = {
|
||||
|
||||
var fullVersion = (match[1] + (match[2] ? '-' + hash : ''));
|
||||
var numVersion = semver[0] + '.' + semver[1] + '.' + semver[2];
|
||||
var version = {
|
||||
version = {
|
||||
number: numVersion,
|
||||
full: fullVersion,
|
||||
major: semver[0],
|
||||
|
||||
Reference in New Issue
Block a user