mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-05-11 20:04:06 +00:00
Save command exit with error when encountering missing tiddlers
Fixes #6603
This commit is contained in:
parent
6624ce3716
commit
73138b79aa
@ -30,13 +30,16 @@ Command.prototype.execute = function() {
|
|||||||
var self = this,
|
var self = this,
|
||||||
fs = require("fs"),
|
fs = require("fs"),
|
||||||
path = require("path"),
|
path = require("path"),
|
||||||
|
result = null,
|
||||||
wiki = this.commander.wiki,
|
wiki = this.commander.wiki,
|
||||||
tiddlerFilter = this.params[0],
|
tiddlerFilter = this.params[0],
|
||||||
filenameFilter = this.params[1] || "[is[tiddler]]",
|
filenameFilter = this.params[1] || "[is[tiddler]]",
|
||||||
tiddlers = wiki.filterTiddlers(tiddlerFilter);
|
tiddlers = wiki.filterTiddlers(tiddlerFilter);
|
||||||
$tw.utils.each(tiddlers,function(title) {
|
$tw.utils.each(tiddlers,function(title) {
|
||||||
var tiddler = self.commander.wiki.getTiddler(title),
|
if(!result) {
|
||||||
type = tiddler.fields.type || "text/vnd.tiddlywiki",
|
var tiddler = self.commander.wiki.getTiddler(title);
|
||||||
|
if(tiddler) {
|
||||||
|
var type = tiddler.fields.type || "text/vnd.tiddlywiki",
|
||||||
contentTypeInfo = $tw.config.contentTypeInfo[type] || {encoding: "utf8"},
|
contentTypeInfo = $tw.config.contentTypeInfo[type] || {encoding: "utf8"},
|
||||||
filepath = path.resolve(self.commander.outputPath,wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]);
|
filepath = path.resolve(self.commander.outputPath,wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]);
|
||||||
if(self.commander.verbose) {
|
if(self.commander.verbose) {
|
||||||
@ -44,10 +47,15 @@ Command.prototype.execute = function() {
|
|||||||
}
|
}
|
||||||
$tw.utils.createFileDirectories(filepath);
|
$tw.utils.createFileDirectories(filepath);
|
||||||
fs.writeFileSync(filepath,tiddler.fields.text,contentTypeInfo.encoding);
|
fs.writeFileSync(filepath,tiddler.fields.text,contentTypeInfo.encoding);
|
||||||
|
} else {
|
||||||
|
result = "Tiddler '" + title + "' not found";
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return null;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.Command = Command;
|
exports.Command = Command;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user