Skip to content

Commit

Permalink
win: make VS path match case-insensitive
Browse files Browse the repository at this point in the history
Fixes: #1805
PR-URL: #1806
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Rod Vagg <[email protected]>
Reviewed-By: Bartosz Sosnowski <[email protected]>
  • Loading branch information
joaocgreis committed Jul 8, 2019
1 parent e40c99e commit 656117c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
33 changes: 32 additions & 1 deletion test/test-find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 656117c

Please sign in to comment.