1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/ReactNativeClient/lib/services/interop/InteropService_Exporter_Raw.ts

29 lines
1.0 KiB
TypeScript
Raw Normal View History

const InteropService_Exporter_Base = require('lib/services/interop/InteropService_Exporter_Base').default;
const BaseItem = require('lib/models/BaseItem.js');
2019-07-29 15:58:33 +02:00
const { basename } = require('lib/path-utils.js');
const shim = require('lib/shim').default;
export default class InteropService_Exporter_Raw extends InteropService_Exporter_Base {
async init(destDir:string) {
this.destDir_ = destDir;
2019-09-19 23:51:18 +02:00
this.resourceDir_ = destDir ? `${destDir}/resources` : null;
await shim.fsDriver().mkdir(this.destDir_);
await shim.fsDriver().mkdir(this.resourceDir_);
}
async processItem(itemType:number, item:any) {
const ItemClass = BaseItem.getClassByItemType(itemType);
const serialized = await ItemClass.serialize(item);
2019-09-19 23:51:18 +02:00
const filePath = `${this.destDir_}/${ItemClass.systemPath(item)}`;
await shim.fsDriver().writeFile(filePath, serialized, 'utf-8');
}
async processResource(_resource:any, filePath:string) {
2019-09-19 23:51:18 +02:00
const destResourcePath = `${this.resourceDir_}/${basename(filePath)}`;
await shim.fsDriver().copy(filePath, destResourcePath);
}
async close() {}
}