@helios-lang/contract-utils 0.2.75 → 0.2.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import * as fs from "node:fs"
|
|
2
|
+
import * as os from "node:os"
|
|
3
|
+
import * as path from "node:path"
|
|
1
4
|
import { contractContextCache } from "./ContractContextCache.js"
|
|
2
5
|
|
|
3
6
|
/**
|
|
@@ -9,24 +12,6 @@ import { contractContextCache } from "./ContractContextCache.js"
|
|
|
9
12
|
* @implements {ExplicitCache}
|
|
10
13
|
*/
|
|
11
14
|
class FileSystemCache {
|
|
12
|
-
/**
|
|
13
|
-
* @private
|
|
14
|
-
* @type {typeof import("node:fs")}
|
|
15
|
-
*/
|
|
16
|
-
fs
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @private
|
|
20
|
-
* @type {typeof import("node:os")}
|
|
21
|
-
*/
|
|
22
|
-
os
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @private
|
|
26
|
-
* @type {typeof import("node:path")}
|
|
27
|
-
*/
|
|
28
|
-
path
|
|
29
|
-
|
|
30
15
|
/**
|
|
31
16
|
* @private
|
|
32
17
|
* @type {string}
|
|
@@ -34,23 +19,13 @@ class FileSystemCache {
|
|
|
34
19
|
cacheDir
|
|
35
20
|
|
|
36
21
|
constructor() {
|
|
37
|
-
|
|
38
|
-
Promise.all([
|
|
39
|
-
import("node:fs"),
|
|
40
|
-
import("node:os"),
|
|
41
|
-
import("node:path")
|
|
42
|
-
]).then(([fs, os, path]) => {
|
|
43
|
-
this.fs = fs
|
|
44
|
-
this.os = os
|
|
45
|
-
this.path = path
|
|
46
|
-
this.cacheDir = this.path.join(this.os.tmpdir(), "helios-cache")
|
|
22
|
+
this.cacheDir = path.join(os.tmpdir(), "helios-cache")
|
|
47
23
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
24
|
+
if (!fs.existsSync(this.cacheDir)) {
|
|
25
|
+
fs.mkdirSync(this.cacheDir, {
|
|
26
|
+
recursive: true
|
|
27
|
+
})
|
|
28
|
+
}
|
|
54
29
|
}
|
|
55
30
|
|
|
56
31
|
/**
|
|
@@ -58,14 +33,14 @@ class FileSystemCache {
|
|
|
58
33
|
* @param {string} key
|
|
59
34
|
*/
|
|
60
35
|
genPath(key) {
|
|
61
|
-
return
|
|
36
|
+
return path.join(this.cacheDir, key + ".json")
|
|
62
37
|
}
|
|
63
38
|
|
|
64
39
|
/**
|
|
65
40
|
* @param {string} key
|
|
66
41
|
*/
|
|
67
42
|
has(key) {
|
|
68
|
-
return
|
|
43
|
+
return fs.existsSync(this.genPath(key))
|
|
69
44
|
}
|
|
70
45
|
|
|
71
46
|
/**
|
|
@@ -73,7 +48,7 @@ class FileSystemCache {
|
|
|
73
48
|
* @returns {JsonSafe}
|
|
74
49
|
*/
|
|
75
50
|
get(key) {
|
|
76
|
-
return JSON.parse(
|
|
51
|
+
return JSON.parse(fs.readFileSync(this.genPath(key)).toString())
|
|
77
52
|
}
|
|
78
53
|
|
|
79
54
|
/**
|
|
@@ -81,7 +56,7 @@ class FileSystemCache {
|
|
|
81
56
|
* @param {JsonSafe} obj
|
|
82
57
|
*/
|
|
83
58
|
set(key, obj) {
|
|
84
|
-
|
|
59
|
+
fs.writeFileSync(this.genPath(key), JSON.stringify(obj))
|
|
85
60
|
}
|
|
86
61
|
}
|
|
87
62
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-fs-build-cache.d.ts","sourceRoot":"","sources":["../../src/context/set-fs-build-cache.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set-fs-build-cache.d.ts","sourceRoot":"","sources":["../../src/context/set-fs-build-cache.js"],"names":[],"mappings":"4BAMa,OAAO,2BAA2B,EAAE,aAAa"}
|