Fix reading msvs version on Windows (#2644)

* fix: fix reading msvs version on windows
This commit is contained in:
James Cook 2023-06-25 08:35:41 -07:00 committed by GitHub
parent b030555cdb
commit 53c99ae573
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View file

@ -85,7 +85,7 @@ function configure (gyp, argv, callback) {
'build dir', '"build" dir needed to be created?', isNew ? 'Yes' : 'No' 'build dir', '"build" dir needed to be created?', isNew ? 'Yes' : 'No'
) )
if (win) { if (win) {
findVisualStudio(release.semver, gyp.opts.msvs_version, findVisualStudio(release.semver, gyp.opts['msvs-version'],
createConfigFile) createConfigFile)
} else { } else {
createPythonSymlink() createPythonSymlink()

View file

@ -60,7 +60,7 @@ proto.configDefs = {
debug: Boolean, // 'build' debug: Boolean, // 'build'
directory: String, // bin directory: String, // bin
make: String, // 'build' make: String, // 'build'
msvs_version: String, // 'configure' 'msvs-version': String, // 'configure'
ensure: Boolean, // 'install' ensure: Boolean, // 'install'
solution: String, // 'build' (windows only) solution: String, // 'build' (windows only)
proxy: String, // 'install' proxy: String, // 'install'

View file

@ -38,4 +38,13 @@ describe('options', function () {
assert.strictEqual(g.opts['force-process-config'], 'true') assert.strictEqual(g.opts['force-process-config'], 'true')
}) })
it('options with msvs_version', () => {
process.env.npm_config_msvs_version = '2017'
const g = gyp()
g.parseArgv(['rebuild']) // Also sets opts.argv.
assert.strictEqual(g.opts['msvs-version'], '2017')
})
}) })