Skip to content

Commit

Permalink
fix: load home path with "os.homedir()" (#24)
Browse files Browse the repository at this point in the history
refactor: define "PLATFORM" once in the global scope
  • Loading branch information
PaulRBerg committed Jan 17, 2023
1 parent df3156c commit 048ecf3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
13 changes: 7 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68343,19 +68343,20 @@ const cache = __nccwpck_require__(7799);
const github = __nccwpck_require__(5438);
const fs = __nccwpck_require__(7147);
const os = __nccwpck_require__(2037);
const path = __nccwpck_require__(1017);

const CACHE_PATHS = ["~/.foundry/cache/rpc"];
const HOME = os.homedir();
const PLATFORM = os.platform();
const CACHE_PATHS = [path.join(HOME, ".foundry/cache/rpc")];

async function restoreRPCCache() {
const platform = os.platform();
const key = platform + "-foundry-chain-fork-" + github.context.sha;
const restoreKeys = [platform + "-foundry-chain-fork-"];
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
const restoreKeys = [PLATFORM + "-foundry-chain-fork-"];
await cache.restoreCache(CACHE_PATHS, key, restoreKeys);
}

async function saveCache() {
const platform = os.platform();
const key = platform + "-foundry-chain-fork-" + github.context.sha;
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
if (fs.existsSync(CACHE_PATHS[0])) {
await cache.saveCache(CACHE_PATHS, key);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66836,19 +66836,20 @@ const cache = __nccwpck_require__(7799);
const github = __nccwpck_require__(5438);
const fs = __nccwpck_require__(7147);
const os = __nccwpck_require__(2037);
const path = __nccwpck_require__(1017);

const CACHE_PATHS = ["~/.foundry/cache/rpc"];
const HOME = os.homedir();
const PLATFORM = os.platform();
const CACHE_PATHS = [path.join(HOME, ".foundry/cache/rpc")];

async function restoreRPCCache() {
const platform = os.platform();
const key = platform + "-foundry-chain-fork-" + github.context.sha;
const restoreKeys = [platform + "-foundry-chain-fork-"];
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
const restoreKeys = [PLATFORM + "-foundry-chain-fork-"];
await cache.restoreCache(CACHE_PATHS, key, restoreKeys);
}

async function saveCache() {
const platform = os.platform();
const key = platform + "-foundry-chain-fork-" + github.context.sha;
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
if (fs.existsSync(CACHE_PATHS[0])) {
await cache.saveCache(CACHE_PATHS, key);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/save/index.js.map

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ const cache = require("@actions/cache");
const github = require("@actions/github");
const fs = require("fs");
const os = require("os");
const path = require("path");

const CACHE_PATHS = ["~/.foundry/cache/rpc"];
const HOME = os.homedir();
const PLATFORM = os.platform();
const CACHE_PATHS = [path.join(HOME, ".foundry/cache/rpc")];

async function restoreRPCCache() {
const platform = os.platform();
const key = platform + "-foundry-chain-fork-" + github.context.sha;
const restoreKeys = [platform + "-foundry-chain-fork-"];
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
const restoreKeys = [PLATFORM + "-foundry-chain-fork-"];
await cache.restoreCache(CACHE_PATHS, key, restoreKeys);
}

async function saveCache() {
const platform = os.platform();
const key = platform + "-foundry-chain-fork-" + github.context.sha;
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
if (fs.existsSync(CACHE_PATHS[0])) {
await cache.saveCache(CACHE_PATHS, key);
}
Expand Down

0 comments on commit 048ecf3

Please sign in to comment.