UNPKG

rdf-dataset-fragmenter

Version:
57 lines 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runConfig = runConfig; exports.runCustom = runCustom; exports.runCli = runCli; const componentsjs_1 = require("componentsjs"); /** * Run function for starting the fragmenter for a given config. * @param configPath - Path to a config. * @param properties - Components loader properties. */ async function runConfig(configPath, properties) { const manager = await componentsjs_1.ComponentsManager.build(properties); await manager.configRegistry.register(configPath); const fragmenter = await manager.instantiate('urn:rdf-dataset-fragmenter:default'); return await fragmenter.fragment(); } ; /** * Generic run function for starting the fragmenter from a given config * @param args - Command line arguments. * @param stdin - Standard input stream. * @param stdout - Standard output stream. * @param stderr - Standard error stream. * @param properties - Components loader properties. */ function runCustom(args, stdin, stdout, stderr, properties) { (async () => { if (args.length !== 1) { stderr.write(`Missing config path argument. Usage: rdf-dataset-fragmenter path/to/config.json `); return; } const configPath = args[0]; // Setup from config file return await runConfig(configPath, properties); })().then(() => { // Done }).catch((error) => { process.stderr.write(`${error.stack}\n`); // eslint-disable-next-line unicorn/no-process-exit process.exit(1); }); } ; /** * Run function for starting the server from the command line * @param moduleRootPath - Path to the module's root. */ function runCli(moduleRootPath) { const argv = process.argv.slice(2); runCustom(argv, process.stdin, process.stdout, process.stderr, { mainModulePath: moduleRootPath }); } ; //# sourceMappingURL=CliRunner.js.map