1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-05-04 00:14:09 +00:00
Mario Pietsch 8aa558eb2c
Remove module function wrapper and add matching configurations for dprint and eslint (#7596)
* remove blks first try

* dprint.json seems to be OK, some forgotten functions

* add some more space-after-keyword settings

* server remove blks

* add **/files to dprint exclude

* dprint.js fixes a typo

* add boot.js and bootprefix.js to dprint exclude

* dprint change dprint.json

* add dprint fmt as script

* remove jslint comments

* fix whitespace

* fix whitespace

* remove function-wrapper from geospatial plugin

* fix whitespace

* add function wrapper to dyannotate-startup

* remove dpring.json
2025-03-21 17:22:57 +00:00

64 lines
1.6 KiB
JavaScript

/*\
title: $:/core/modules/commands/save.js
type: application/javascript
module-type: command
Saves individual tiddlers in their raw text or binary format to the specified files
\*/
"use strict";
exports.info = {
name: "save",
synchronous: true
};
var Command = function(params,commander,callback) {
this.params = params;
this.commander = commander;
this.callback = callback;
};
Command.prototype.execute = function() {
if(this.params.length < 1) {
return "Missing filename filter";
}
var self = this,
fs = require("fs"),
path = require("path"),
result = null,
wiki = this.commander.wiki,
tiddlerFilter = this.params[0],
filenameFilter = this.params[1] || "[is[tiddler]]",
tiddlers = wiki.filterTiddlers(tiddlerFilter);
$tw.utils.each(tiddlers,function(title) {
if(!result) {
var tiddler = self.commander.wiki.getTiddler(title);
if(tiddler) {
var fileInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{
directory: path.resolve(self.commander.outputPath),
pathFilters: [filenameFilter],
wiki: wiki,
fileInfo: {
overwrite: true
}
});
if(self.commander.verbose) {
console.log("Saving \"" + title + "\" to \"" + fileInfo.filepath + "\"");
}
try {
$tw.utils.saveTiddlerToFileSync(tiddler,fileInfo);
} catch (err) {
result = "Error saving tiddler \"" + title + "\", to file: \"" + fileInfo.filepath + "\"";
}
} else {
result = "Tiddler '" + title + "' not found";
}
}
});
return result;
};
exports.Command = Command;