Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomek0123456789 committed Dec 15, 2023
1 parent c60cba5 commit 064ca49
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 40 deletions.
30 changes: 15 additions & 15 deletions dist/cache-save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59390,7 +59390,7 @@ var core = __nccwpck_require__(2186);
// EXTERNAL MODULE: ./node_modules/@actions/cache/lib/cache.js
var cache = __nccwpck_require__(7799);
// EXTERNAL MODULE: ./node_modules/@actions/exec/lib/exec.js
var lib_exec = __nccwpck_require__(1514);
var exec = __nccwpck_require__(1514);
// EXTERNAL MODULE: ./node_modules/@actions/glob/lib/glob.js
var lib_glob = __nccwpck_require__(8090);
// EXTERNAL MODULE: external "os"
Expand Down Expand Up @@ -59423,7 +59423,7 @@ async function getCacheDirectory() {
core.debug(`scarb cache path fallback failed: ${e.message}`);
}

const { stdout, exitCode } = await lib_exec.getExecOutput("scarb cache path");
const { stdout, exitCode } = await exec.getExecOutput("scarb cache path");

if (exitCode > 0) {
throw new Error(
Expand All @@ -59435,7 +59435,7 @@ async function getCacheDirectory() {
}

async function isScarbMissingCachePathCommand() {
const { stdout } = await lib_exec.getExecOutput("scarb -V");
const { stdout } = await exec.getExecOutput("scarb -V");
return stdout.match(/^scarb 0\.[0-6]\./) != null;
}

Expand Down Expand Up @@ -59469,20 +59469,16 @@ async function getCacheKey() {
}

async function getScarbLockfilePath() {
const { stdout, exitCode } = await exec.getExecOutput("scarb manifest-path");
const globber = await glob.create("**/Scarb.lock");
const lockfiles = await globber.glob();

if (exitCode > 0) {
throw new Error(
"failed to find Scarb.toml: command `scarb manifest-path` failed",
);
}

const lockfilePath = stdout.trim().slice(0, -4) + "lock";
await exec.getExecOutput("test -f " + lockfilePath).catch((_) => {
if (lockfiles.length === 0) {
throw new Error("failed to find Scarb.lock");
});
}

return lockfilePath;
return lockfiles.reduce((prev, next) =>
prev.length < next.length ? prev : next,
);
}

;// CONCATENATED MODULE: ./lib/cache-save.js
Expand All @@ -59499,7 +59495,11 @@ async function saveCache() {
if (primaryKey !== matchedKey) {
await cache.saveCache([await getCacheDirectory()], primaryKey);
} else if (primaryKey === "" && matchedKey === "") {
core.info(`No cache to validate from.`);
// When using action for the first time and the project doesn't have Scarb.lock,
// `restoreCache()` returns an error during `getCacheKey()` method.
// As a result, primaryKey and matchedKey (by default) are empty strings,
// which would satisfy `else` branch, even though no cache would be found.
core.info(`Cache entry not found, not saving cache.`);
} else {
core.info(`Cache hit occurred, not saving cache.`);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/cache-save/index.js.map

Large diffs are not rendered by default.

18 changes: 7 additions & 11 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60652,20 +60652,16 @@ async function getCacheKey() {
}

async function getScarbLockfilePath() {
const { stdout, exitCode } = await exec.getExecOutput("scarb manifest-path");
const globber = await glob.create("**/Scarb.lock");
const lockfiles = await globber.glob();

if (exitCode > 0) {
throw new Error(
"failed to find Scarb.toml: command `scarb manifest-path` failed",
);
}

const lockfilePath = stdout.trim().slice(0, -4) + "lock";
await exec.getExecOutput("test -f " + lockfilePath).catch((_) => {
if (lockfiles.length === 0) {
throw new Error("failed to find Scarb.lock");
});
}

return lockfilePath;
return lockfiles.reduce((prev, next) =>
prev.length < next.length ? prev : next,
);
}

;// CONCATENATED MODULE: ./lib/cache-restore.js
Expand Down
2 changes: 1 addition & 1 deletion dist/setup/index.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion lib/cache-save.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ async function saveCache() {
if (primaryKey !== matchedKey) {
await cache.saveCache([await getCacheDirectory()], primaryKey);
} else if (primaryKey === "" && matchedKey === "") {
core.info(`No cache to validate from.`);
// When using action for the first time and the project doesn't have Scarb.lock,
// `restoreCache()` returns an error during `getCacheKey()` method.
// As a result, primaryKey and matchedKey (by default) are empty strings,
// which would satisfy `else` branch, even though no cache would be found.
core.info(`Cache entry not found, not saving cache.`);
} else {
core.info(`Cache hit occurred, not saving cache.`);
}
Expand Down
18 changes: 7 additions & 11 deletions lib/cache-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,14 @@ export async function getCacheKey() {
}

async function getScarbLockfilePath() {
const { stdout, exitCode } = await exec.getExecOutput("scarb manifest-path");
const globber = await glob.create("**/Scarb.lock");
const lockfiles = await globber.glob();

if (exitCode > 0) {
throw new Error(
"failed to find Scarb.toml: command `scarb manifest-path` failed",
);
}

const lockfilePath = stdout.trim().slice(0, -4) + "lock";
await exec.getExecOutput("test -f " + lockfilePath).catch((_) => {
if (lockfiles.length === 0) {
throw new Error("failed to find Scarb.lock");
});
}

return lockfilePath;
return lockfiles.reduce((prev, next) =>
prev.length < next.length ? prev : next,
);
}

0 comments on commit 064ca49

Please sign in to comment.