From 52c6bd02479be0c446306a3359b22a7568a0800c Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 23 Feb 2018 08:54:18 +1030 Subject: [PATCH] use SystemRoot environment variable, if set --- app/src/lib/is-git-on-path.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/lib/is-git-on-path.ts b/app/src/lib/is-git-on-path.ts index a62bcc8385a..25f5e58c8ce 100644 --- a/app/src/lib/is-git-on-path.ts +++ b/app/src/lib/is-git-on-path.ts @@ -1,4 +1,5 @@ import { spawn } from 'child_process' +import * as Path from 'path' export function isGitOnPath(): Promise { // Modern versions of macOS ship with a Git shim that guides you through @@ -12,16 +13,19 @@ export function isGitOnPath(): Promise { // adapted from http://stackoverflow.com/a/34953561/1363815 return new Promise((resolve, reject) => { if (__WIN32__) { - const process = spawn('C:\\Windows\\System32\\where.exe', ['git']) + const windowsRoot = process.env.SystemRoot || 'C:\\Windows' + const wherePath = Path.join(windowsRoot, 'System32', 'where.exe') - process.on('error', error => { + const cp = spawn(wherePath, ['git']) + + cp.on('error', error => { log.warn('Unable to spawn where.exe', error) resolve(false) }) // `where` will return 0 when the executable // is found under PATH, or 1 if it cannot be found - process.on('close', function(code) { + cp.on('close', function(code) { resolve(code === 0) }) return