Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b53c945

Browse files
committed
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.
1 parent 724819e commit b53c945

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/grunt/utils.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var fs = require('fs');
22
var shell = require('shelljs');
33
var grunt = require('grunt');
44
var spawn = require('child_process').spawn;
5+
var version;
56

67
module.exports = {
78

@@ -11,14 +12,16 @@ module.exports = {
1112

1213

1314
getVersion: function(){
15+
if (version) return version;
16+
1417
var package = JSON.parse(fs.readFileSync('package.json', 'UTF-8'));
1518
var match = package.version.match(/^([^\-]*)(-snapshot)?$/);
1619
var semver = match[1].split('.');
1720
var hash = shell.exec('git rev-parse --short HEAD', {silent: true}).output.replace('\n', '');
1821

1922
var fullVersion = (match[1] + (match[2] ? '-' + hash : ''));
2023
var numVersion = semver[0] + '.' + semver[1] + '.' + semver[2];
21-
var version = {
24+
version = {
2225
number: numVersion,
2326
full: fullVersion,
2427
major: semver[0],

0 commit comments

Comments
 (0)