* use filesystem utils

* use filesystem utils

* don't touch syncer

* fix messaging
This commit is contained in:
Joshua Fontany 2022-04-19 00:18:44 -07:00 committed by GitHub
parent 8dec674121
commit 42bf203758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -39,14 +39,20 @@ Saves individual tiddlers in their raw text or binary format to the specified fi
if(!result) {
var tiddler = self.commander.wiki.getTiddler(title);
if(tiddler) {
var type = tiddler.fields.type || "text/vnd.tiddlywiki",
contentTypeInfo = $tw.config.contentTypeInfo[type] || {encoding: "utf8"},
filepath = path.resolve(self.commander.outputPath,wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]);
var fileInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{
directory: path.resolve(self.commander.outputPath),
pathFilters: [filenameFilter],
wiki: wiki,
fileInfo: {}
});
if(self.commander.verbose) {
console.log("Saving \"" + title + "\" to \"" + filepath + "\"");
console.log("Saving \"" + title + "\" to \"" + fileInfo.filepath + "\"");
}
try {
$tw.utils.saveTiddlerToFileSync(tiddler,fileInfo);
} catch (err) {
result = "Error saving tiddler \"" + title + "\", to file: \"" + fileInfo.filepath + "\"";
}
$tw.utils.createFileDirectories(filepath);
fs.writeFileSync(filepath,tiddler.fields.text,contentTypeInfo.encoding);
} else {
result = "Tiddler '" + title + "' not found";
}