From 656117cc4a5c8f3342641413e2baa024f7d4e819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Thu, 4 Jul 2019 12:07:24 +0100 Subject: [PATCH] win: make VS path match case-insensitive Fixes: https://github.com/nodejs/node-gyp/issues/1805 PR-URL: https://github.com/nodejs/node-gyp/pull/1806 Reviewed-By: Richard Lau Reviewed-By: Rod Vagg Reviewed-By: Bartosz Sosnowski --- lib/find-visualstudio.js | 6 ++++-- test/test-find-visualstudio.js | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib/find-visualstudio.js b/lib/find-visualstudio.js index 6799b66ce0..b2c00e6835 100644 --- a/lib/find-visualstudio.js +++ b/lib/find-visualstudio.js @@ -405,11 +405,13 @@ VisualStudioFinder.prototype = { this.addLog('- msvs_version does not match this version') return false } - if (this.configPath && this.configPath !== vsPath) { + if (this.configPath && + path.relative(this.configPath, vsPath) !== '') { this.addLog('- msvs_version does not point to this installation') return false } - if (this.envVcInstallDir && this.envVcInstallDir !== vsPath) { + if (this.envVcInstallDir && + path.relative(this.envVcInstallDir, vsPath) !== '') { this.addLog('- does not match this Visual Studio Command Prompt') return false } diff --git a/test/test-find-visualstudio.js b/test/test-find-visualstudio.js index acbe7000da..b00adf0227 100644 --- a/test/test-find-visualstudio.js +++ b/test/test-find-visualstudio.js @@ -525,7 +525,7 @@ test('look for VS2019 by version number', function (t) { finder.findVisualStudio() }) -test('look for VS2017 by installation path', function (t) { +test('look for VS2019 by installation path', function (t) { t.plan(2) const finder = new TestVisualStudioFinder(semverV1, @@ -540,6 +540,21 @@ test('look for VS2017 by installation path', function (t) { finder.findVisualStudio() }) +test('msvs_version match should be case insensitive', function (t) { + t.plan(2) + + const finder = new TestVisualStudioFinder(semverV1, + 'c:\\program files (x86)\\microsoft visual studio\\2019\\BUILDTOOLS', + (err, info) => { + t.strictEqual(err, null) + t.deepEqual(info.path, + 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools') + }) + + allVsVersions(t, finder) + finder.findVisualStudio() +}) + test('latest version should be found by default', function (t) { t.plan(2) @@ -568,6 +583,22 @@ test('run on a usable VS Command Prompt', function (t) { finder.findVisualStudio() }) +test('VCINSTALLDIR match should be case insensitive', function (t) { + t.plan(2) + + process.env.VCINSTALLDIR = + 'c:\\program files (x86)\\microsoft visual studio\\2019\\BUILDTOOLS\\VC' + + const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => { + t.strictEqual(err, null) + t.deepEqual(info.path, + 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools') + }) + + allVsVersions(t, finder) + finder.findVisualStudio() +}) + test('run on a unusable VS Command Prompt', function (t) { t.plan(2)