Skip to content

Commit 048ecf3

Browse files
authored
fix: load home path with "os.homedir()" (#24)
refactor: define "PLATFORM" once in the global scope
1 parent df3156c commit 048ecf3

File tree

6 files changed

+27
-22
lines changed

6 files changed

+27
-22
lines changed

dist/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68343,19 +68343,20 @@ const cache = __nccwpck_require__(7799);
6834368343
const github = __nccwpck_require__(5438);
6834468344
const fs = __nccwpck_require__(7147);
6834568345
const os = __nccwpck_require__(2037);
68346+
const path = __nccwpck_require__(1017);
6834668347

68347-
const CACHE_PATHS = ["~/.foundry/cache/rpc"];
68348+
const HOME = os.homedir();
68349+
const PLATFORM = os.platform();
68350+
const CACHE_PATHS = [path.join(HOME, ".foundry/cache/rpc")];
6834868351

6834968352
async function restoreRPCCache() {
68350-
const platform = os.platform();
68351-
const key = platform + "-foundry-chain-fork-" + github.context.sha;
68352-
const restoreKeys = [platform + "-foundry-chain-fork-"];
68353+
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
68354+
const restoreKeys = [PLATFORM + "-foundry-chain-fork-"];
6835368355
await cache.restoreCache(CACHE_PATHS, key, restoreKeys);
6835468356
}
6835568357

6835668358
async function saveCache() {
68357-
const platform = os.platform();
68358-
const key = platform + "-foundry-chain-fork-" + github.context.sha;
68359+
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
6835968360
if (fs.existsSync(CACHE_PATHS[0])) {
6836068361
await cache.saveCache(CACHE_PATHS, key);
6836168362
}

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/save/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66836,19 +66836,20 @@ const cache = __nccwpck_require__(7799);
6683666836
const github = __nccwpck_require__(5438);
6683766837
const fs = __nccwpck_require__(7147);
6683866838
const os = __nccwpck_require__(2037);
66839+
const path = __nccwpck_require__(1017);
6683966840

66840-
const CACHE_PATHS = ["~/.foundry/cache/rpc"];
66841+
const HOME = os.homedir();
66842+
const PLATFORM = os.platform();
66843+
const CACHE_PATHS = [path.join(HOME, ".foundry/cache/rpc")];
6684166844

6684266845
async function restoreRPCCache() {
66843-
const platform = os.platform();
66844-
const key = platform + "-foundry-chain-fork-" + github.context.sha;
66845-
const restoreKeys = [platform + "-foundry-chain-fork-"];
66846+
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
66847+
const restoreKeys = [PLATFORM + "-foundry-chain-fork-"];
6684666848
await cache.restoreCache(CACHE_PATHS, key, restoreKeys);
6684766849
}
6684866850

6684966851
async function saveCache() {
66850-
const platform = os.platform();
66851-
const key = platform + "-foundry-chain-fork-" + github.context.sha;
66852+
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
6685266853
if (fs.existsSync(CACHE_PATHS[0])) {
6685366854
await cache.saveCache(CACHE_PATHS, key);
6685466855
}

dist/save/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cache.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ const cache = require("@actions/cache");
22
const github = require("@actions/github");
33
const fs = require("fs");
44
const os = require("os");
5+
const path = require("path");
56

6-
const CACHE_PATHS = ["~/.foundry/cache/rpc"];
7+
const HOME = os.homedir();
8+
const PLATFORM = os.platform();
9+
const CACHE_PATHS = [path.join(HOME, ".foundry/cache/rpc")];
710

811
async function restoreRPCCache() {
9-
const platform = os.platform();
10-
const key = platform + "-foundry-chain-fork-" + github.context.sha;
11-
const restoreKeys = [platform + "-foundry-chain-fork-"];
12+
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
13+
const restoreKeys = [PLATFORM + "-foundry-chain-fork-"];
1214
await cache.restoreCache(CACHE_PATHS, key, restoreKeys);
1315
}
1416

1517
async function saveCache() {
16-
const platform = os.platform();
17-
const key = platform + "-foundry-chain-fork-" + github.context.sha;
18+
const key = PLATFORM + "-foundry-chain-fork-" + github.context.sha;
1819
if (fs.existsSync(CACHE_PATHS[0])) {
1920
await cache.saveCache(CACHE_PATHS, key);
2021
}

0 commit comments

Comments
 (0)