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 <riclau@uk.ibm.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
This commit is contained in:
João Reis 2019-07-04 12:07:24 +01:00
parent e40c99e283
commit 656117cc4a
2 changed files with 36 additions and 3 deletions

View file

@ -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
}

View file

@ -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)