Comparing version 0.1.3 to 0.2.0
@@ -42,5 +42,5 @@ "use strict"; | ||
const cacheFullPath = (0, path_1.join)(cacheDir, `${fnName}-${argsHash}.json`); | ||
if ((0, fs_1.existsSync)(cacheFullPath)) { | ||
if (await exists(cacheFullPath)) { | ||
(0, logger_1.debug)("Hit the cache %s", (0, path_1.relative)(cwd, cacheFullPath)); | ||
const content = (0, fs_1.readFileSync)(cacheFullPath, "utf-8"); | ||
const content = await (0, promises_1.readFile)(cacheFullPath, "utf-8"); | ||
return JSON.parse(content); | ||
@@ -50,3 +50,3 @@ } | ||
const serialized = JSON.stringify(result); | ||
(0, fs_1.writeFileSync)(cacheFullPath, serialized); | ||
await (0, promises_1.writeFile)(cacheFullPath, serialized); | ||
(0, logger_1.debug)("Cached %s", (0, path_1.relative)(cwd, cacheFullPath)); | ||
@@ -58,2 +58,11 @@ return result; | ||
} | ||
async function exists(path) { | ||
try { | ||
await (0, promises_1.access)(path, fs_1.constants.F_OK); | ||
} | ||
catch (e) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
async function clearCache({ dir = defaultDir, enable = true } = {}) { | ||
@@ -60,0 +69,0 @@ const cacheDir = (0, path_1.join)(cwd, dir); |
{ | ||
"name": "memo-json", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -14,17 +14,17 @@ "homepage": "https://github.com/piglovesyou/memo-json", | ||
"devDependencies": { | ||
"@babel/plugin-proposal-decorators": "7.15.8", | ||
"@babel/preset-env": "7.15.8", | ||
"@babel/preset-typescript": "7.15.0", | ||
"@babel/plugin-proposal-decorators": "7.17.2", | ||
"@babel/preset-env": "7.16.11", | ||
"@babel/preset-typescript": "7.16.7", | ||
"@types/debug": "4.1.7", | ||
"@types/jest": "27.0.2", | ||
"@types/node": "16.10.3", | ||
"husky": "7.0.2", | ||
"jest": "27.2.4", | ||
"@types/jest": "27.4.0", | ||
"@types/node": "16.11.24", | ||
"husky": "7.0.4", | ||
"jest": "27.4.5", | ||
"prettier": "2.4.1", | ||
"prettier-plugin-organize-imports": "2.3.4", | ||
"pretty-quick": "3.1.1", | ||
"typescript": "4.4.3" | ||
"pretty-quick": "3.1.3", | ||
"typescript": "4.5.5" | ||
}, | ||
"dependencies": { | ||
"debug": "4.3.2", | ||
"debug": "4.3.3", | ||
"make-dir": "2.1.0" | ||
@@ -31,0 +31,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6679
104
+ Addeddebug@4.3.3(transitive)
- Removeddebug@4.3.2(transitive)
Updateddebug@4.3.3