Pretty print settings file json
Summary: Making it a bit more human readable. Reviewed By: passy Differential Revision: D18271880 fbshipit-source-id: 10e8ba50957e9407b1436972f8a06915edf73dfb
This commit is contained in:
committed by
Facebook Github Bot
parent
6e69d20917
commit
61d4e0c6a5
@@ -1 +1,10 @@
|
|||||||
{"androidHome":"/opt/android_sdk","something":{"else":4},"_persist":{"version":-1,"rehydrated":true}}
|
{
|
||||||
|
"androidHome": "/opt/android_sdk",
|
||||||
|
"something": {
|
||||||
|
"else": 4
|
||||||
|
},
|
||||||
|
"_persist": {
|
||||||
|
"version": -1,
|
||||||
|
"rehydrated": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export default class JsonFileStorage {
|
|||||||
console.warn(
|
console.warn(
|
||||||
`Failed to read settings file: "${this.filepath}". ${e}. Replacing file with default settings.`,
|
`Failed to read settings file: "${this.filepath}". ${e}. Replacing file with default settings.`,
|
||||||
);
|
);
|
||||||
return this.writeContents(JSON.stringify({})).then(() => ({}));
|
return this.writeContents(prettyStringify({})).then(() => ({}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ export default class JsonFileStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeItem(_key: string, callback?: () => any): Promise<void> {
|
removeItem(_key: string, callback?: () => any): Promise<void> {
|
||||||
return this.writeContents(JSON.stringify({}))
|
return this.writeContents(prettyStringify({}))
|
||||||
.then(_ => callback && callback())
|
.then(_ => callback && callback())
|
||||||
.then(() => {});
|
.then(() => {});
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ export default class JsonFileStorage {
|
|||||||
acc[cv[0]] = cv[1];
|
acc[cv[0]] = cv[1];
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
return JSON.stringify(reconstructedObject);
|
return prettyStringify(reconstructedObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
deserializeValue(value: string): string {
|
deserializeValue(value: string): string {
|
||||||
@@ -95,3 +95,7 @@ export default class JsonFileStorage {
|
|||||||
.then(() => promises.writeFile(this.filepath, content));
|
.then(() => promises.writeFile(this.filepath, content));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prettyStringify(data: Object) {
|
||||||
|
return JSON.stringify(data, null, 2);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user