From 53c99ae573bd5a5435e843b7de6b2e684f4de4d3 Mon Sep 17 00:00:00 2001 From: James Cook Date: Sun, 25 Jun 2023 08:35:41 -0700 Subject: [PATCH] Fix reading msvs version on Windows (#2644) * fix: fix reading msvs version on windows --- lib/configure.js | 2 +- lib/node-gyp.js | 2 +- test/test-options.js | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/configure.js b/lib/configure.js index 97dccc6db8..bcd8bb23ea 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -85,7 +85,7 @@ function configure (gyp, argv, callback) { 'build dir', '"build" dir needed to be created?', isNew ? 'Yes' : 'No' ) if (win) { - findVisualStudio(release.semver, gyp.opts.msvs_version, + findVisualStudio(release.semver, gyp.opts['msvs-version'], createConfigFile) } else { createPythonSymlink() diff --git a/lib/node-gyp.js b/lib/node-gyp.js index 21d12460c8..392a0ecfa6 100644 --- a/lib/node-gyp.js +++ b/lib/node-gyp.js @@ -60,7 +60,7 @@ proto.configDefs = { debug: Boolean, // 'build' directory: String, // bin make: String, // 'build' - msvs_version: String, // 'configure' + 'msvs-version': String, // 'configure' ensure: Boolean, // 'install' solution: String, // 'build' (windows only) proxy: String, // 'install' diff --git a/test/test-options.js b/test/test-options.js index 24e79c80a1..8d281db8e8 100644 --- a/test/test-options.js +++ b/test/test-options.js @@ -38,4 +38,13 @@ describe('options', function () { 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') + }) })