Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win: make VS path match case-insensitive #1806

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,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