2020-10-09 19:35:46 +02:00
|
|
|
import { ImportExportResult } from './types';
|
2021-01-22 19:41:11 +02:00
|
|
|
import InteropService_Importer_Base from './InteropService_Importer_Base';
|
|
|
|
import Folder from '../../models/Folder';
|
2020-11-05 18:58:23 +02:00
|
|
|
const { filename } = require('../../path-utils');
|
2018-02-26 21:25:54 +02:00
|
|
|
|
2020-10-09 19:35:46 +02:00
|
|
|
export default class InteropService_Importer_EnexToHtml extends InteropService_Importer_Base {
|
2021-01-22 19:41:11 +02:00
|
|
|
async exec(result: ImportExportResult): Promise<ImportExportResult> {
|
2020-11-05 18:58:23 +02:00
|
|
|
const { importEnex } = require('../../import-enex');
|
2018-02-27 22:04:38 +02:00
|
|
|
|
2018-02-26 21:25:54 +02:00
|
|
|
let folder = this.options_.destinationFolder;
|
|
|
|
|
|
|
|
if (!folder) {
|
2018-06-27 22:45:31 +02:00
|
|
|
const folderTitle = await Folder.findUniqueItemTitle(filename(this.sourcePath_));
|
2018-02-26 21:25:54 +02:00
|
|
|
folder = await Folder.save({ title: folderTitle });
|
|
|
|
}
|
|
|
|
|
2020-02-05 00:09:34 +02:00
|
|
|
await importEnex(folder.id, this.sourcePath_, { ...this.options_, outputFormat: 'html' });
|
2018-02-26 21:25:54 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|