passalong 0.15.0 → 0.15.1
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/store.js +7 -1
package/package.json
CHANGED
package/src/store.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
mkdirSync,
|
|
11
11
|
readdirSync,
|
|
12
12
|
readFileSync,
|
|
13
|
+
renameSync,
|
|
13
14
|
statSync,
|
|
14
15
|
unlinkSync,
|
|
15
16
|
writeFileSync,
|
|
@@ -40,7 +41,12 @@ export function readConfig() {
|
|
|
40
41
|
export function writeConfig(patch) {
|
|
41
42
|
ensure();
|
|
42
43
|
const next = { ...readConfig(), ...patch };
|
|
43
|
-
|
|
44
|
+
// Written beside it and renamed over it, so a reader never meets a half-written file: the update
|
|
45
|
+
// check rewrites this from a background process, and a command that read it mid-write saw no
|
|
46
|
+
// accounts at all.
|
|
47
|
+
const tmp = `${CONFIG}.${process.pid}.tmp`;
|
|
48
|
+
writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
|
|
49
|
+
renameSync(tmp, CONFIG);
|
|
44
50
|
return next;
|
|
45
51
|
}
|
|
46
52
|
|