UNPKG

dolphin-tool

Version:

🐬 dolphin-tool binaries and wrapper for Node.js.

44 lines 2.06 kB
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()); }); }; import DolphinToolBin from './dolphinToolBin.js'; export default { listFiles(options_1) { return __awaiter(this, arguments, void 0, function* (options, attempt = 1) { const output = yield DolphinToolBin.run([ 'extract', '-i', options.inputFilename, '-l', ], options); const files = output.split(/\r?\n/) .filter((line) => line.trim().length > 0); // Try to detect failures, and then retry them automatically if (files.length === 0) { yield new Promise((resolve) => { setTimeout(resolve, Math.random() * (Math.pow(2, (attempt - 1)) * 20)); }); return this.listFiles(options, attempt + 1); } return files; }); }, extract(options) { return __awaiter(this, void 0, void 0, function* () { yield DolphinToolBin.run([ 'extract', '-i', options.inputFilename, '-o', options.outputFolder, ...(options.partition ? ['-p', options.partition] : []), ...(options.single ? ['-s', options.single] : []), ...(options.gameOnly ? ['-g'] : []), ], options); }); }, }; //# sourceMappingURL=dolphinToolExtract.js.map