mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-15 23:07:18 +00:00
Introduce JSON parse utility function with error handling (#6401)
* Introduce JSON parse utility function with error handling Fixes #6400 * Fix typo
This commit is contained in:
@@ -48,7 +48,7 @@ Command.prototype.execute = function() {
|
||||
}
|
||||
// Tweak the tiddlywiki.info to remove any included wikis
|
||||
var packagePath = $tw.boot.wikiPath + "/tiddlywiki.info",
|
||||
packageJson = JSON.parse(fs.readFileSync(packagePath));
|
||||
packageJson = $tw.utils.parseJSONSafe(fs.readFileSync(packagePath));
|
||||
delete packageJson.includeWikis;
|
||||
fs.writeFileSync(packagePath,JSON.stringify(packageJson,null,$tw.config.preferences.jsonSpaces));
|
||||
return null;
|
||||
|
||||
@@ -69,7 +69,7 @@ Command.prototype.execute = function() {
|
||||
$tw.utils.createFileDirectories(pathname);
|
||||
fs.writeFileSync(pathname,JSON.stringify(tiddler),"utf8");
|
||||
// Collect the skinny list data
|
||||
var pluginTiddlers = JSON.parse(tiddler.text),
|
||||
var pluginTiddlers = $tw.utils.parseJSONSafe(tiddler.text),
|
||||
readmeContent = (pluginTiddlers.tiddlers[title + "/readme"] || {}).text,
|
||||
doesRequireReload = !!self.commander.wiki.doesPluginInfoRequireReload(pluginTiddlers),
|
||||
iconTiddler = pluginTiddlers.tiddlers[title + "/icon"] || {},
|
||||
|
||||
@@ -151,7 +151,7 @@ WikiFolderMaker.prototype.saveCustomPlugin = function(pluginTiddler) {
|
||||
pluginInfo = pluginTiddler.getFieldStrings({exclude: ["text","type"]});
|
||||
this.saveJSONFile(directory + path.sep + "plugin.info",pluginInfo);
|
||||
self.log("Writing " + directory + path.sep + "plugin.info: " + JSON.stringify(pluginInfo,null,$tw.config.preferences.jsonSpaces));
|
||||
var pluginTiddlers = JSON.parse(pluginTiddler.fields.text).tiddlers; // A hashmap of tiddlers in the plugin
|
||||
var pluginTiddlers = $tw.utils.parseJSONSafe(pluginTiddler.fields.text).tiddlers; // A hashmap of tiddlers in the plugin
|
||||
$tw.utils.each(pluginTiddlers,function(tiddler) {
|
||||
self.saveTiddler(directory,new $tw.Tiddler(tiddler));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user