From 8029e048b2ee5a749d7f945b9322f585252eca1f Mon Sep 17 00:00:00 2001 From: Chris Earle Date: Wed, 18 Jan 2017 23:17:57 -0500 Subject: [PATCH] Allow build configuration to run on Windows machines (#9951) --- tasks/config/build.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tasks/config/build.js b/tasks/config/build.js index 2cceff4957bb..5005717095bd 100644 --- a/tasks/config/build.js +++ b/tasks/config/build.js @@ -1,11 +1,19 @@ import { execSync as exec } from 'child_process'; +const platform = require('os').platform(); export default (grunt) => { const pkgVersion = grunt.config.get('pkg.version'); const sha = String(exec('git rev-parse HEAD')).trim(); - const number = parseFloat(String(exec('git log --format="%h" | wc -l')).trim()); const version = buildVersion(grunt.option('release'), pkgVersion); + let number; + + if (/^win/.test(platform)) { + // Windows does not have the wc process and `find /C /V ""` does not consistently work + number = String(exec('git log --format="%h"')).split('\n').length; + } else { + number = parseFloat(String(exec('git log --format="%h" | wc -l')).trim()); + } return { sha, number, version }; };