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

fix: support visual studio 2022 #40

Merged
merged 2 commits into from
Jun 22, 2022
Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
pnpm:
- 6
include:
- os: windows-2022
node_version: 12.18.3
arch: x64
pnpm: 6
- os: windows-2019
node_version: 12.18.3
arch: x86
Expand Down
16 changes: 8 additions & 8 deletions src/apm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function x86ProgramFilesDirectory() {
return process.env["ProgramFiles(x86)"] || process.env.ProgramFiles
}

export function getInstalledVisualStudioFlag() {
export function getInstalledVisualStudioFlag(): string {
if (!isWin32()) {
return null
}
Expand All @@ -149,18 +149,18 @@ export function getInstalledVisualStudioFlag() {
return process.env.GYP_MSVS_VERSION
}

if (visualStudioIsInstalled("2019")) {
return "2019"
}
if (visualStudioIsInstalled("2017")) {
return "2017"
for (const vsVersion of [2022, 2019, 2017]) {
if (visualStudioIsInstalled(vsVersion)) {
return String(vsVersion)
}
}
if (visualStudioIsInstalled("14.0")) {

if (visualStudioIsInstalled(14.0)) {
return "2015"
}
}

export function visualStudioIsInstalled(version) {
export function visualStudioIsInstalled(version: number): boolean {
if (version < 2017) {
return fs.existsSync(path.join(x86ProgramFilesDirectory(), `Microsoft Visual Studio ${version}`, "Common7", "IDE"))
} else {
Expand Down