UNPKG

yarle-evernote-to-md

Version:

Yet Another Rope Ladder from Evernote

67 lines 3.03 kB
"use strict"; /* istanbul ignore file */ // tslint:disable:no-console var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.run = void 0; const fs = __importStar(require("fs")); const path = __importStar(require("path")); const yarle = __importStar(require("./yarle")); const loggerInfo_1 = require("./utils/loggerInfo"); const clearLogFile_1 = require("./utils/clearLogFile"); const apply_links_1 = require("./utils/apply-links"); const LanguageFactory_1 = require("./outputLanguages/LanguageFactory"); const run = async (opts) => { (0, clearLogFile_1.clearLogFile)(); // tslint:disable-next-line:no-require-imports const argv = require('minimist')(process.argv.slice(2)); const configFile = argv['configFile'] ? path.isAbsolute(argv['configFile']) ? argv['configFile'] : `${process.cwd()}/${argv['configFile']}` : `${__dirname}/../config.json`; console.log(`Loading config from ${configFile}`); const options = Object.assign(Object.assign({}, require(configFile)), opts); if (options.enexSources.length === 1 && options.enexSources[0].endsWith('.enex')) { (0, loggerInfo_1.loggerInfo)(`Converting notes in file: ${options.enexSources}`); } else { const enexFiles = fs .readdirSync(options.enexSources[0]) .filter((file) => { return file.match(/.*\.enex/ig); }); options.enexSources = enexFiles.map(enexFile => `${options.enexSources[0]}${path.sep}${enexFile}`); } const outputNotebookFolders = await yarle.dropTheRope(options); // POSTPROCESSES // apply internal links (0, apply_links_1.applyLinks)(options, outputNotebookFolders); const langaugeFactory = new LanguageFactory_1.LanguageFactory(); const targetLanguage = langaugeFactory.createLanguage(options.outputFormat); await targetLanguage.postProcess(options, outputNotebookFolders); }; exports.run = run; //# sourceMappingURL=dropTheRopeRunner.js.map