1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/ReactNativeClient/lib/services/InteropService_Importer_Jex.js
Laurent Cozic 71efff6827
Linter update (#1777)
* Update eslint config

* Applied linter to lib

* Applied eslint config to CliClient/app

* Removed prettier due to https://github.com/prettier/prettier/pull/4765

* First pass on test units

* Applied linter config to test units

* Applied eslint config to clipper

* Applied to plugin dir

* Applied to root of ElectronClient

* Applied on RN root

* Applied on CLI root

* Applied on Clipper root

* Applied config to tools

* test hook

* test hook

* test hook

* Added pre-commit hook

* Applied rule no-trailing-spaces

* Make sure root packages are installed when installing sub-dir

* Added doc
2019-07-30 09:35:42 +02:00

37 lines
1.1 KiB
JavaScript

const InteropService_Importer_Base = require('lib/services/InteropService_Importer_Base');
const InteropService_Importer_Raw = require('lib/services/InteropService_Importer_Raw');
const { filename } = require('lib/path-utils.js');
const fs = require('fs-extra');
class InteropService_Importer_Jex extends InteropService_Importer_Base {
async exec(result) {
const tempDir = await this.temporaryDirectory_(true);
try {
await require('tar').extract({
strict: true,
portable: true,
file: this.sourcePath_,
cwd: tempDir,
});
} catch (error) {
let msg = ['Cannot untar file ' + this.sourcePath_, error.message];
if (error.data) msg.push(JSON.stringify(error.data));
let e = new Error(msg.join(': '));
throw e;
}
if (!('defaultFolderTitle' in this.options_)) this.options_.defaultFolderTitle = filename(this.sourcePath_);
const importer = new InteropService_Importer_Raw();
await importer.init(tempDir, this.options_);
result = await importer.exec(result);
await fs.remove(tempDir);
return result;
}
}
module.exports = InteropService_Importer_Jex;