Skip to content

Commit

Permalink
Small fixes in caching logic (#12)
Browse files Browse the repository at this point in the history
See particular commits for details
  • Loading branch information
mkaput authored Aug 11, 2023
1 parent 608d5f2 commit 67ef98b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
12 changes: 7 additions & 5 deletions dist/cache-save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59372,11 +59372,11 @@ function getCacheDirectory() {
case "linux":
return external_path_default().join(home, ".cache/scarb");
case "darwin":
return external_path_default().join(home, `Library/Caches/com.swmansion.Scarb`);
return external_path_default().join(home, `Library/Caches/com.swmansion.scarb`);
case "win32":
return external_path_default().join(process.env.APPDATA, "swmansion/Scarb/config");
return external_path_default().join(process.env.APPDATA, "swmansion/scarb/config");
default:
throw new Error(`Caching not available for ${platform} platform.`);
throw new Error(`caching is not available on this platform: ${platform}`);
}
}

Expand All @@ -59386,7 +59386,7 @@ async function getCacheKey() {

if (!fileHash) {
throw new Error(
"Unable to hash Scarb.toml file, cannot cache dependencies.",
"failed to cache dependencies: unable to hash Scarb.toml file",
);
}

Expand All @@ -59397,7 +59397,9 @@ async function getScarbManifestPath() {
const { stdout, exitCode } = await exec.getExecOutput("scarb manifest-path");

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

return stdout.trim();
Expand Down
2 changes: 1 addition & 1 deletion dist/cache-save/index.js.map

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60534,11 +60534,11 @@ function getCacheDirectory() {
case "linux":
return external_path_default().join(home, ".cache/scarb");
case "darwin":
return external_path_default().join(home, `Library/Caches/com.swmansion.Scarb`);
return external_path_default().join(home, `Library/Caches/com.swmansion.scarb`);
case "win32":
return external_path_default().join(process.env.APPDATA, "swmansion/Scarb/config");
return external_path_default().join(process.env.APPDATA, "swmansion/scarb/config");
default:
throw new Error(`Caching not available for ${platform} platform.`);
throw new Error(`caching is not available on this platform: ${platform}`);
}
}

Expand All @@ -60548,7 +60548,7 @@ async function getCacheKey() {

if (!fileHash) {
throw new Error(
"Unable to hash Scarb.toml file, cannot cache dependencies.",
"failed to cache dependencies: unable to hash Scarb.toml file",
);
}

Expand All @@ -60559,7 +60559,9 @@ async function getScarbManifestPath() {
const { stdout, exitCode } = await exec.getExecOutput("scarb manifest-path");

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

return stdout.trim();
Expand Down
2 changes: 1 addition & 1 deletion dist/setup/index.js.map

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions lib/cache-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export function getCacheDirectory() {
case "linux":
return path.join(home, ".cache/scarb");
case "darwin":
return path.join(home, `Library/Caches/com.swmansion.Scarb`);
return path.join(home, `Library/Caches/com.swmansion.scarb`);
case "win32":
return path.join(process.env.APPDATA, "swmansion/Scarb/config");
return path.join(process.env.APPDATA, "swmansion/scarb/config");
default:
throw new Error(`Caching not available for ${platform} platform.`);
throw new Error(`caching is not available on this platform: ${platform}`);
}
}

Expand All @@ -31,7 +31,7 @@ export async function getCacheKey() {

if (!fileHash) {
throw new Error(
"Unable to hash Scarb.toml file, cannot cache dependencies.",
"failed to cache dependencies: unable to hash Scarb.toml file",
);
}

Expand All @@ -42,7 +42,9 @@ async function getScarbManifestPath() {
const { stdout, exitCode } = await exec.getExecOutput("scarb manifest-path");

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

return stdout.trim();
Expand Down

0 comments on commit 67ef98b

Please sign in to comment.