Skip to content

Commit 64ad11e

Browse files
committed
Add platform input param and fix error catching
1 parent 938903f commit 64ad11e

File tree

7 files changed

+25
-16
lines changed

7 files changed

+25
-16
lines changed

__tests__/main.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ describe('action', () => {
4545
return '15.0.0'
4646
case 'unzip-to':
4747
return tmpDir
48+
case 'platform':
49+
return 'linux_x64'
4850
default:
4951
return ''
5052
}

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ inputs:
1717
description: 'Where to unzip the Qt Creator files to'
1818
required: true
1919
default: 'qt-creator'
20+
platform:
21+
description: 'Overwrite platform detection'
22+
required: false
2023

2124
# Define your outputs here.
2225
outputs:

badges/coverage.svg

+1-1
Loading

dist/index.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+9-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,18 @@ export async function run(): Promise<void> {
7474
try {
7575
const version: string = core.getInput('version')
7676
const destination: string = core.getInput('unzip-to')
77+
const platformInput: string = core.getInput('platform')
7778

78-
if (!(process.platform in PlatformMap)) {
79+
if (!platformInput && !(process.platform in PlatformMap)) {
7980
core.setFailed(`Unsupported platform: ${process.platform}`)
8081
return
8182
}
8283

8384
const platformName: string =
8485
PlatformMap[process.platform as keyof typeof PlatformMap]
8586
const arch = process.platform === 'darwin' ? 'x64' : process.arch
86-
const platform = `${platformName}_${arch}`
87+
88+
const platform = platformInput ? platformInput : `${platformName}_${arch}`
8789

8890
// Extract the major and minor versions
8991
const [major, minor] = version.split('.').slice(0, 2)
@@ -116,6 +118,6 @@ export async function run(): Promise<void> {
116118
)
117119
} catch (error) {
118120
// Fail the workflow run if an error occurs
119-
if (error instanceof Error) core.setFailed(error.message)
121+
core.setFailed((error as Error).message)
120122
}
121123
}

0 commit comments

Comments
 (0)