Skip to content

Commit

Permalink
fix: remove double resolving package versions (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric authored Jan 17, 2022
1 parent 7934883 commit d53d38f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
17 changes: 8 additions & 9 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 @@ -65246,16 +65246,15 @@ 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;
if (!cliPath && cache) {
cliPath = await (0, cacher_1.restoreFromCache)(name, cliVersion, packager);
async function installCli(name, version, packager, useCache = true) {
let cliPath = (0, worker_1.findTool)(name, version) || undefined;
if (!cliPath && useCache) {
cliPath = await (0, cacher_1.restoreFromCache)(name, version, packager);
}
if (!cliPath) {
cliPath = await (0, packager_1.installPackage)(name, cliVersion, packager);
if (cache) {
await (0, cacher_1.saveToCache)(name, cliVersion, packager);
cliPath = await (0, packager_1.installPackage)(name, version, packager);
if (useCache) {
await (0, cacher_1.saveToCache)(name, version, packager);
}
}
(0, worker_1.installToolFromPackage)(cliPath);
Expand Down
17 changes: 8 additions & 9 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 @@ -59,19 +59,18 @@ 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;
async function installCli(name: string, version: string, packager: string, useCache = true) {
let cliPath = findTool(name, version) || undefined;

if (!cliPath && cache) {
cliPath = await restoreFromCache(name, cliVersion, packager);
if (!cliPath && useCache) {
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);
if (useCache) {
await saveToCache(name, version, packager);
}
}

Expand Down

0 comments on commit d53d38f

Please sign in to comment.