1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/ReactNativeClient/lib/services/InteropService_Exporter_Base.js
Vaidotas Simkus d9d75d6c71 Desktop, Cli: Replace note links with relative paths in MD Exporter (#2161)
* Replace linked Note ids by relative paths in MD Exporter.

* Added tests for the MD Exporter.

* Changed fs.readdirSync use for earlier Node version (v8)

In the previous commit the code used fs.readdirSync from Node v10 or
later. But since Joplin still uses v8, I changed the use of
fs.readdirSync to be in line with the earlier api.

* Updated readDirSync use for Node v10, which allows gets folder names too.

* Revert "Updated readDirSync use for Node v10, which allows gets folder names too."

This reverts commit 8f255db120861dd7773d99e1b63f4864d39594cf.
Because the Travis builds still use Node v8. This is fine as well, the
readdirSync returns the filenames in the directory.

* Added reservedNames param to findUniqueFilename
2020-01-18 13:16:14 +00:00

41 lines
926 B
JavaScript

/* eslint @typescript-eslint/no-unused-vars: 0, no-unused-vars: ["error", { "argsIgnorePattern": ".*" }], */
const Setting = require('lib/models/Setting');
class InteropService_Exporter_Base {
constructor() {
this.context_ = {};
}
async init(destDir) {}
async prepareForProcessingItemType(type, itemsToExport) {}
async processItem(ItemClass, item) {}
async processResource(resource, filePath) {}
async close() {}
setMetadata(md) {
this.metadata_ = md;
}
metadata() {
return this.metadata_;
}
updateContext(context) {
this.context_ = Object.assign(this.context_, context);
}
context() {
return this.context_;
}
async temporaryDirectory_(createIt) {
const md5 = require('md5');
const tempDir = `${Setting.value('tempDir')}/${md5(Math.random() + Date.now())}`;
if (createIt) await require('fs-extra').mkdirp(tempDir);
return tempDir;
}
}
module.exports = InteropService_Exporter_Base;