2018-02-26 21:25:54 +02:00
|
|
|
const InteropService_Exporter_Base = require('lib/services/InteropService_Exporter_Base');
|
2019-07-29 15:58:33 +02:00
|
|
|
const { basename } = require('lib/path-utils.js');
|
2018-02-26 21:25:54 +02:00
|
|
|
const { shim } = require('lib/shim');
|
|
|
|
|
|
|
|
class InteropService_Exporter_Raw extends InteropService_Exporter_Base {
|
|
|
|
async init(destDir) {
|
|
|
|
this.destDir_ = destDir;
|
2019-09-19 23:51:18 +02:00
|
|
|
this.resourceDir_ = destDir ? `${destDir}/resources` : null;
|
2018-02-26 21:25:54 +02:00
|
|
|
|
|
|
|
await shim.fsDriver().mkdir(this.destDir_);
|
|
|
|
await shim.fsDriver().mkdir(this.resourceDir_);
|
|
|
|
}
|
|
|
|
|
|
|
|
async processItem(ItemClass, item) {
|
|
|
|
const serialized = await ItemClass.serialize(item);
|
2019-09-19 23:51:18 +02:00
|
|
|
const filePath = `${this.destDir_}/${ItemClass.systemPath(item)}`;
|
2018-02-26 21:25:54 +02:00
|
|
|
await shim.fsDriver().writeFile(filePath, serialized, 'utf-8');
|
|
|
|
}
|
|
|
|
|
|
|
|
async processResource(resource, filePath) {
|
2019-09-19 23:51:18 +02:00
|
|
|
const destResourcePath = `${this.resourceDir_}/${basename(filePath)}`;
|
2018-02-26 21:25:54 +02:00
|
|
|
await shim.fsDriver().copy(filePath, destResourcePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
async close() {}
|
|
|
|
}
|
|
|
|
|
2019-07-29 15:43:53 +02:00
|
|
|
module.exports = InteropService_Exporter_Raw;
|