mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00: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:
parent
64e447354e
commit
edef295b11
1 changed files with 8 additions and 2 deletions
|
|
@ -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],
|
||||
|
|
|
|||
Loading…
Reference in a new issue