Skip to content

Commit 86839db

Browse files
Improve available versions output if version is not found (#34)
1 parent 2cc17b7 commit 86839db

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The list of all available versions can be found in [virtual-environments](https:
66
# Available parameters
77
| Argument | Description | Format |
88
|-------------------------|--------------------------|--------------------|
9-
| `xcode-version` | Specify the Xcode version to use | - `latest` or<br> - `latest-stable` or<br> - [SemVer](https://semver.org/) string or<br> - [SemVer](https://semver.org/)`-beta` |
9+
| `xcode-version` | Specify the Xcode version to use | - `latest` or<br> - `latest-stable` or<br> - [SemVer](https://semver.org/) string or<br> - `<semver>-beta` |
1010

1111
**Notes:**
1212
- `latest-stable` points to the latest stable version of Xcode
@@ -43,22 +43,22 @@ Set the specific stable version of Xcode:
4343
```
4444
jobs:
4545
build:
46-
runs-on: macos-latest
46+
runs-on: macos-11
4747
steps:
4848
- uses: maxim-lobanov/setup-xcode@v1
4949
with:
50-
xcode-version: '12.0'
50+
xcode-version: '13.0'
5151
```
5252

5353
Set the specific beta version of Xcode:
5454
```
5555
jobs:
5656
build:
57-
runs-on: macos-latest
57+
runs-on: macos-11
5858
steps:
5959
- uses: maxim-lobanov/setup-xcode@v1
6060
with:
61-
xcode-version: '12.0-beta'
61+
xcode-version: '13.0-beta'
6262
```
6363
# License
6464
The scripts and documentation in this project are released under the [MIT License](LICENSE)

dist/index.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
2929
Object.defineProperty(exports, "__esModule", ({ value: true }));
3030
const core = __importStar(__webpack_require__(2186));
3131
const xcode_selector_1 = __webpack_require__(8865);
32-
const os_1 = __webpack_require__(2087);
3332
const run = () => {
3433
try {
3534
if (process.platform !== "darwin") {
@@ -45,11 +44,9 @@ const run = () => {
4544
}
4645
const targetVersion = selector.findVersion(versionSpec);
4746
if (!targetVersion) {
48-
throw new Error([
49-
`Could not find Xcode version that satisfied version spec: '${versionSpec}'`,
50-
"Available versions:",
51-
...selector.getAllVersions().map(ver => `- ${ver.version} (${ver.path})`),
52-
].join(os_1.EOL));
47+
console.log("Available versions:");
48+
console.table(selector.getAllVersions());
49+
throw new Error(`Could not find Xcode version that satisfied version spec: '${versionSpec}'`);
5350
}
5451
core.debug(`Xcode ${targetVersion.version} (${targetVersion.buildNumber}) (${targetVersion.path}) will be set`);
5552
selector.setVersion(targetVersion);

src/setup-xcode.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as core from "@actions/core";
22
import { XcodeSelector } from "./xcode-selector";
3-
import { EOL } from "os";
43

54
const run = (): void => {
65
try {
@@ -22,12 +21,10 @@ const run = (): void => {
2221
const targetVersion = selector.findVersion(versionSpec);
2322

2423
if (!targetVersion) {
24+
console.log("Available versions:");
25+
console.table(selector.getAllVersions());
2526
throw new Error(
26-
[
27-
`Could not find Xcode version that satisfied version spec: '${versionSpec}'`,
28-
"Available versions:",
29-
...selector.getAllVersions().map(ver => `- ${ver.version} (${ver.path})`),
30-
].join(EOL)
27+
`Could not find Xcode version that satisfied version spec: '${versionSpec}'`
3128
);
3229
}
3330

0 commit comments

Comments
 (0)