utilium 3.10.0 → 3.11.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/dist/fs.d.ts +5 -0
- package/dist/fs.js +2 -2
- package/package.json +1 -1
package/dist/fs.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ export interface JSONFileMapOptions {
|
|
|
23
23
|
* Should an invalid JSON file be overwritten
|
|
24
24
|
*/
|
|
25
25
|
overwrite_invalid: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* When set, format the JSON nicely.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
pretty?: boolean;
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
28
33
|
* A Map overlaying a JSON file
|
package/dist/fs.js
CHANGED
|
@@ -75,8 +75,8 @@ export class JSONFileMap extends FileMap {
|
|
|
75
75
|
if (!fs.existsSync(this.path)) {
|
|
76
76
|
fs.writeFileSync(this.path, '{}');
|
|
77
77
|
}
|
|
78
|
-
const content = JSON.stringify(Object.fromEntries(map));
|
|
79
|
-
fs.writeFileSync(this.path, content);
|
|
78
|
+
const content = JSON.stringify(Object.fromEntries(map), null, this.options.pretty ? '\t' : undefined);
|
|
79
|
+
fs.writeFileSync(this.path, this.options.pretty ? content + '\n' : content);
|
|
80
80
|
}
|
|
81
81
|
clear() {
|
|
82
82
|
fs.writeFileSync(this.path, '{}');
|