Skip to content

Commit

Permalink
fix: remove double resolving package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Jan 17, 2022
1 parent 7934883 commit fe882d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
11 changes: 5 additions & 6 deletions build/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65230,7 +65230,7 @@ async function setupAction(input = setupInput()) {
const message = input.easCache
? `Installing eas-cli (${version}) from cache or with ${input.packager}`
: `Installing eas-cli (${version}) with ${input.packager}`;
await (0, core_1.group)(message, () => installCli('eas-cli', input.easVersion, input.packager, input.easCache));
await (0, core_1.group)(message, () => installCli('eas-cli', version, input.packager, input.easCache));
}
if (!input.token) {
(0, core_1.info)(`Skipped authentication: 'token' not provided.`);
Expand All @@ -65247,15 +65247,14 @@ async function setupAction(input = setupInput()) {
}
exports.setupAction = setupAction;
async function installCli(name, version, packager, cache = true) {
const cliVersion = await (0, packager_1.resolvePackage)(name, version);
let cliPath = (0, worker_1.findTool)(name, cliVersion) || undefined;
let cliPath = (0, worker_1.findTool)(name, version) || undefined;
if (!cliPath && cache) {
cliPath = await (0, cacher_1.restoreFromCache)(name, cliVersion, packager);
cliPath = await (0, cacher_1.restoreFromCache)(name, version, packager);
}
if (!cliPath) {
cliPath = await (0, packager_1.installPackage)(name, cliVersion, packager);
cliPath = await (0, packager_1.installPackage)(name, version, packager);
if (cache) {
await (0, cacher_1.saveToCache)(name, cliVersion, packager);
await (0, cacher_1.saveToCache)(name, version, packager);
}
}
(0, worker_1.installToolFromPackage)(cliPath);
Expand Down
4 changes: 4 additions & 0 deletions preview-comment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ inputs:
message-id:
description: A unique identifier to prevent multiple comments on the same pull request
required: false
github-token:
description: Fallback GitHub token to use if GITHUB_TOKEN is undefined
required: false
default: ${{ github.token }}
outputs:
projectOwner:
description: The resolved project owner
Expand Down
11 changes: 5 additions & 6 deletions src/actions/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function setupAction(input: SetupInput = setupInput()) {
? `Installing eas-cli (${version}) from cache or with ${input.packager}`
: `Installing eas-cli (${version}) with ${input.packager}`;

await group(message, () => installCli('eas-cli', input.easVersion, input.packager, input.easCache));
await group(message, () => installCli('eas-cli', version, input.packager, input.easCache));
}

if (!input.token) {
Expand All @@ -60,18 +60,17 @@ export async function setupAction(input: SetupInput = setupInput()) {
}

async function installCli(name: string, version: string, packager: string, cache: boolean = true) {
const cliVersion = await resolvePackage(name, version);
let cliPath = findTool(name, cliVersion) || undefined;
let cliPath = findTool(name, version) || undefined;

if (!cliPath && cache) {
cliPath = await restoreFromCache(name, cliVersion, packager);
cliPath = await restoreFromCache(name, version, packager);
}

if (!cliPath) {
cliPath = await installPackage(name, cliVersion, packager);
cliPath = await installPackage(name, version, packager);

if (cache) {
await saveToCache(name, cliVersion, packager);
await saveToCache(name, version, packager);
}
}

Expand Down

0 comments on commit fe882d7

Please sign in to comment.