Skip to content

Commit 296bf7f

Browse files
committed
Use an explicit list of supported platforms for nicer error messages
1 parent e92b797 commit 296bf7f

File tree

5 files changed

+37
-2
lines changed

5 files changed

+37
-2
lines changed

common.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ function getImageOS() {
9898
return imageOS
9999
}
100100

101+
export const supportedPlatforms = [
102+
'ubuntu-18.04',
103+
'ubuntu-20.04',
104+
'macos-10.15',
105+
'macos-11.0',
106+
'windows-2019',
107+
'windows-2022',
108+
]
109+
101110
export function getVirtualEnvironmentName() {
102111
const imageOS = getImageOS()
103112

dist/index.js

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function setupRuby(options = {}) {
4242
const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version'])
4343

4444
let installer
45-
if (platform.startsWith('windows-') && engine !== 'jruby') {
45+
if (platform.startsWith('windows-') && engine === 'ruby') {
4646
installer = require('./windows')
4747
} else {
4848
installer = require('./ruby-builder')

ruby-builder.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
1313
const windows = common.windows
1414

1515
export function getAvailableVersions(platform, engine) {
16+
if (!common.supportedPlatforms.includes(platform)) {
17+
throw new Error(`Unsupported platform ${platform}`)
18+
}
19+
1620
return rubyBuilderVersions[engine]
1721
}
1822

windows.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const msysPathEntries = [`${msys1}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys1}\\
2525
const virtualEnv = common.getVirtualEnvironmentName()
2626

2727
export function getAvailableVersions(platform, engine) {
28+
if (!common.supportedPlatforms.includes(platform)) {
29+
throw new Error(`Unsupported platform ${platform}`)
30+
}
31+
2832
if (engine === 'ruby') {
2933
return Object.keys(rubyInstallerVersions)
3034
} else {

0 commit comments

Comments
 (0)