Skip to content

Commit 656117c

Browse files
committed
win: make VS path match case-insensitive
Fixes: #1805 PR-URL: #1806 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
1 parent e40c99e commit 656117c

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

lib/find-visualstudio.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,13 @@ VisualStudioFinder.prototype = {
405405
this.addLog('- msvs_version does not match this version')
406406
return false
407407
}
408-
if (this.configPath && this.configPath !== vsPath) {
408+
if (this.configPath &&
409+
path.relative(this.configPath, vsPath) !== '') {
409410
this.addLog('- msvs_version does not point to this installation')
410411
return false
411412
}
412-
if (this.envVcInstallDir && this.envVcInstallDir !== vsPath) {
413+
if (this.envVcInstallDir &&
414+
path.relative(this.envVcInstallDir, vsPath) !== '') {
413415
this.addLog('- does not match this Visual Studio Command Prompt')
414416
return false
415417
}

test/test-find-visualstudio.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ test('look for VS2019 by version number', function (t) {
525525
finder.findVisualStudio()
526526
})
527527

528-
test('look for VS2017 by installation path', function (t) {
528+
test('look for VS2019 by installation path', function (t) {
529529
t.plan(2)
530530

531531
const finder = new TestVisualStudioFinder(semverV1,
@@ -540,6 +540,21 @@ test('look for VS2017 by installation path', function (t) {
540540
finder.findVisualStudio()
541541
})
542542

543+
test('msvs_version match should be case insensitive', function (t) {
544+
t.plan(2)
545+
546+
const finder = new TestVisualStudioFinder(semverV1,
547+
'c:\\program files (x86)\\microsoft visual studio\\2019\\BUILDTOOLS',
548+
(err, info) => {
549+
t.strictEqual(err, null)
550+
t.deepEqual(info.path,
551+
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools')
552+
})
553+
554+
allVsVersions(t, finder)
555+
finder.findVisualStudio()
556+
})
557+
543558
test('latest version should be found by default', function (t) {
544559
t.plan(2)
545560

@@ -568,6 +583,22 @@ test('run on a usable VS Command Prompt', function (t) {
568583
finder.findVisualStudio()
569584
})
570585

586+
test('VCINSTALLDIR match should be case insensitive', function (t) {
587+
t.plan(2)
588+
589+
process.env.VCINSTALLDIR =
590+
'c:\\program files (x86)\\microsoft visual studio\\2019\\BUILDTOOLS\\VC'
591+
592+
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
593+
t.strictEqual(err, null)
594+
t.deepEqual(info.path,
595+
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools')
596+
})
597+
598+
allVsVersions(t, finder)
599+
finder.findVisualStudio()
600+
})
601+
571602
test('run on a unusable VS Command Prompt', function (t) {
572603
t.plan(2)
573604

0 commit comments

Comments
 (0)