Repository URL to install this package:
| 
      
        
        
        Version: 
        
         
          
          3.1.7  ▾
        
         | 
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runtime = exports.declaration = void 0;
const InteropService_1 = require("@joplin/lib/services/interop/InteropService");
const types_1 = require("@joplin/lib/services/interop/types");
const shim_1 = require("@joplin/lib/shim");
exports.declaration = {
    name: 'exportFolders',
};
const runtime = () => {
    return {
        // "targetPath" should be a file for JEX export (because the format can
        // contain multiple folders) or a directory otherwise.
        // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
        execute: (_context, folderIds, format, targetPath) => __awaiter(void 0, void 0, void 0, function* () {
            const exportOptions = {
                sourceFolderIds: folderIds,
                path: targetPath,
                format: format,
                target: types_1.FileSystemItem.Directory,
            };
            const targetMustBeFile = format === 'jex';
            const targetIsDir = yield shim_1.default.fsDriver().isDirectory(targetPath);
            if (targetMustBeFile && targetIsDir) {
                throw new Error(`Format "${format}" can only be exported to a file`);
            }
            if (format === 'jex' || !targetIsDir) {
                exportOptions.target = types_1.FileSystemItem.File;
            }
            return InteropService_1.default.instance().export(exportOptions);
        }),
    };
};
exports.runtime = runtime;
//# sourceMappingURL=exportFolders.js.map