windows-autoconf
Advanced tools
Comparing version 1.9.1 to 1.9.6
12
index.js
@@ -143,7 +143,8 @@ 'use strict' | ||
function tryRegistryMSBuild () { | ||
function tryRegistryMSBuild (ver) { | ||
try { | ||
const msbSetups = execAndParse(module.exports.try_registry_msbuild_path) | ||
const vers = msbSetups.map(s => s['ver']).sort().reverse() | ||
const msbSetup = msbSetups.find(s => s['ver'] === vers[0]) | ||
const vers = msbSetups.map(s => s['ver']) | ||
ver = Number(ver) || Math.max.apply(null, vers) | ||
const msbSetup = msbSetups.find(s => s['ver'] === ver) | ||
return msbSetup | ||
@@ -162,4 +163,5 @@ } catch (e) { | ||
function locateMsbuild () { | ||
const msbSetup = locateMSBuild2017() || tryRegistryMSBuild() | ||
function locateMsbuild (ver) { | ||
ver = ver || 'auto' | ||
const msbSetup = ((ver in {2017: 1, auto: 1}) && locateMSBuild2017()) || tryRegistryMSBuild(ver) | ||
if (!msbSetup) { | ||
@@ -166,0 +168,0 @@ lazy.bindings.log('Can\'t find "msbuild.exe"') |
{ | ||
"name": "windows-autoconf", | ||
"version": "1.9.1", | ||
"version": "1.9.6", | ||
"description": "Try to find MS build tools", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,3 +15,3 @@ /* eslint-disable no-path-concat */ | ||
const prods = new Set(['BuildTools', 'Enterprise', 'Professional', 'Community']) | ||
function checkCom() { | ||
function checkCom () { | ||
let ret | ||
@@ -21,3 +21,2 @@ try { | ||
} catch (e) { | ||
console.error(e) | ||
assert.equal(e.status, 1) | ||
@@ -53,3 +52,3 @@ ret = e.output[1].toString().trim() | ||
const csfile = getter.try_powershell_path.replace(/\\[^\\]+$/, '\\GetVS2017Configuration.cs').replace('"', '') | ||
const cmd = `"powershell.exe" -Version 2 -ExecutionPolicy Unrestricted -Command "&{ Add-Type -Path '${csfile}'; [VisualStudioConfiguration.Main]::Query()}"` | ||
const cmd = `"powershell.exe" -Version 2 -NoProfile -ExecutionPolicy Unrestricted -Command "& { Add-Type -Path '${csfile}'; [VisualStudioConfiguration.Main]::Query()}"` | ||
const ret = getter._forTesting.execAndParse(cmd) | ||
@@ -311,2 +310,27 @@ const setup = ret[0] | ||
it('locateMsbuild(auto)', () => { | ||
const msbPath = getter.locateMsbuild('auto') | ||
const parts = msbPath.split('\\') | ||
assert(parts.length >= 4) | ||
assert(parts.pop() === 'MSBuild.exe') | ||
assert(fs.existsSync(msbPath)) | ||
}) | ||
it('locateMsbuild(2017)', function () { | ||
const msbPath = getter.locateMsbuild(2017) | ||
if (!msbPath) this.skip() | ||
const parts = msbPath.split('\\') | ||
assert(parts.length >= 4) | ||
assert(parts.pop() === 'MSBuild.exe') | ||
assert(fs.existsSync(msbPath)) | ||
}) | ||
it('locateMsbuild(4)', () => { | ||
const msbPath = getter.locateMsbuild(4) | ||
const parts = msbPath.split('\\') | ||
assert(parts.length >= 4) | ||
assert(parts.pop() === 'MSBuild.exe') | ||
assert(msbPath.includes('\\v4.')) | ||
assert(fs.existsSync(msbPath)) | ||
}) | ||
}) | ||
@@ -313,0 +337,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43066
658