1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Enhance savetiddlers command with do not delete option

This commit is contained in:
Jermolene 2015-09-03 08:54:17 +01:00
parent 4ccdaf3faf
commit 5176f008f0
2 changed files with 7 additions and 2 deletions

View File

@ -4,9 +4,11 @@ description: Saves a group of raw tiddlers to a directory
Saves a group of tiddlers in their raw text or binary format to the specified directory.
```
--savetiddlers <filter> <pathname>
--savetiddlers <filter> <pathname> [-do-not-delete]
```
By default, the pathname is resolved relative to the `output` subdirectory of the edition directory. The `--output` command can be used to direct output to a different directory.
The output directory is cleared of existing files before saving the specified files. The deletion can be disabled by specifying the ''-do-not-delete'' flag.
Any missing directories in the pathname are automatically created.

View File

@ -35,8 +35,11 @@ Command.prototype.execute = function() {
wiki = this.commander.wiki,
filter = this.params[0],
pathname = path.resolve(this.commander.outputPath,this.params[1]),
dontDelete = (this.params[2] || "").toLowerCase() === "-do-not-delete",
tiddlers = wiki.filterTiddlers(filter);
$tw.utils.deleteDirectory(pathname);
if(!dontDelete) {
$tw.utils.deleteDirectory(pathname);
}
$tw.utils.createDirectory(pathname);
$tw.utils.each(tiddlers,function(title) {
var tiddler = self.commander.wiki.getTiddler(title),