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

Commit edef295

Browse files
IgorMinarbtford
authored andcommitted
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 64e4473 commit edef295

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/grunt/utils.js

+8-2
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,13 +12,18 @@ 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

19-
var version = {
20-
full: (match[1] + (match[2] ? '-' + hash : '')),
22+
var fullVersion = (match[1] + (match[2] ? '-' + hash : ''));
23+
var numVersion = semver[0] + '.' + semver[1] + '.' + semver[2];
24+
version = {
25+
number: numVersion,
26+
full: fullVersion,
2127
major: semver[0],
2228
minor: semver[1],
2329
dot: semver[2],

0 commit comments

Comments
 (0)