Skip to content

Commit

Permalink
Merge pull request #333 from sidepelican/versioncheck
Browse files Browse the repository at this point in the history
Fix error output on Linux
  • Loading branch information
fwal authored Nov 29, 2021
2 parents a94947b + 85dfe5b commit dea3ae0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions __tests__/get-version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ Target: x86_64-apple-macosx11.0`
);
expect(version).toBe("5.5");
});

it("identifies version from swift version on linux", async () => {
const version = versionFromString(
"Swift version 5.5.1 (swift-5.5.1-RELEASE)"
);
expect(version).toBe("5.5.1");
});
});
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2751,7 +2751,7 @@ function run() {
core.setOutput("version", version);
}
else {
core.error("Failed to setup requested swift version");
core.error(`Failed to setup requested swift version. requestd: ${version}, actual: ${current}`);
}
}
catch (error) {
Expand Down Expand Up @@ -13725,7 +13725,7 @@ function getVersion(command = "swift", args = ["--version"]) {
}
exports.getVersion = getVersion;
function versionFromString(subject) {
const match = subject.match(/Apple\ Swift\ version (?<version>[0-9]+\.[0-9+]+(\.[0-9]+)?)/) || {
const match = subject.match(/Swift\ version (?<version>[0-9]+\.[0-9+]+(\.[0-9]+)?)/) || {
groups: { version: null },
};
if (!match.groups || !match.groups.version) {
Expand Down
2 changes: 1 addition & 1 deletion src/get-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function getVersion(

export function versionFromString(subject: string): string | null {
const match = subject.match(
/Apple\ Swift\ version (?<version>[0-9]+\.[0-9+]+(\.[0-9]+)?)/
/Swift\ version (?<version>[0-9]+\.[0-9+]+(\.[0-9]+)?)/
) || {
groups: { version: null },
};
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ async function run() {
if (current === version) {
core.setOutput("version", version);
} else {
core.error("Failed to setup requested swift version");
core.error(
`Failed to setup requested swift version. requestd: ${version}, actual: ${current}`
);
}
} catch (error) {
let dump: String;
Expand Down

0 comments on commit dea3ae0

Please sign in to comment.