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_Raw.js
2019-09-19 22:51:18 +01:00

29 lines
946 B
JavaScript

const InteropService_Exporter_Base = require('lib/services/InteropService_Exporter_Base');
const { basename } = require('lib/path-utils.js');
const { shim } = require('lib/shim');
class InteropService_Exporter_Raw extends InteropService_Exporter_Base {
async init(destDir) {
this.destDir_ = destDir;
this.resourceDir_ = destDir ? `${destDir}/resources` : null;
await shim.fsDriver().mkdir(this.destDir_);
await shim.fsDriver().mkdir(this.resourceDir_);
}
async processItem(ItemClass, item) {
const serialized = await ItemClass.serialize(item);
const filePath = `${this.destDir_}/${ItemClass.systemPath(item)}`;
await shim.fsDriver().writeFile(filePath, serialized, 'utf-8');
}
async processResource(resource, filePath) {
const destResourcePath = `${this.resourceDir_}/${basename(filePath)}`;
await shim.fsDriver().copy(filePath, destResourcePath);
}
async close() {}
}
module.exports = InteropService_Exporter_Raw;