pi-hashline-edit-pro 0.16.8 → 0.16.9
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 +1 -1
- package/src/hash-store.ts +4 -3
package/package.json
CHANGED
package/src/hash-store.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { readFile,
|
|
1
|
+
import { readFile, mkdir } from "fs/promises";
|
|
2
2
|
import { stat } from "fs/promises";
|
|
3
3
|
import { hashStorePath, hashStoreDir } from "./paths";
|
|
4
4
|
import { errCode } from "./validation";
|
|
5
|
+
import { writeAtomic } from "./fs-write";
|
|
5
6
|
|
|
6
7
|
export interface FileSnapshot {
|
|
7
8
|
content: string;
|
|
@@ -30,14 +31,14 @@ export async function loadHashStore(): Promise<HashStore> {
|
|
|
30
31
|
version: 1,
|
|
31
32
|
snapshots: {},
|
|
32
33
|
};
|
|
33
|
-
await
|
|
34
|
+
await writeAtomic(hashStorePath(), JSON.stringify(defaultStore));
|
|
34
35
|
return defaultStore;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export async function saveHashStore(store: HashStore): Promise<void> {
|
|
39
40
|
await mkdir(hashStoreDir(), { recursive: true });
|
|
40
|
-
await
|
|
41
|
+
await writeAtomic(hashStorePath(), JSON.stringify(store, null, 2));
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export async function pruneHashStore(store: HashStore): Promise<void> {
|