UNPKG

gulp-armapbo

Version:

The plugin for Gulp which allows to pack ArmA pbo files from sources.

40 lines (38 loc) 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const headerEntry_1 = require("../domain/headerEntry"); const headerExtension_1 = require("../domain/headerExtension"); const header_1 = require("../domain/header"); const packingMethod_1 = require("../domain/packingMethod"); const pboFormatter_1 = require("./pboFormatter"); const packingFuncFactory_1 = require("./packingFuncFactory"); class PboBuilder { build(files, options) { const extensions = options.extensions && Array.isArray(options.extensions) ? options.extensions.map(ext => new headerExtension_1.HeaderExtension(ext.name, ext.value)) : []; const getPackingMethod = packingFuncFactory_1.PackingFuncFactory.getPackingFunc(options); const entries = files.filter(file => !!file.contents).map(file => { const fileData = file.contents; const timeStamp = file.stat.mtime.getTime() / 1000; const packingMethod = getPackingMethod(file); const entry = new headerEntry_1.HeaderEntry(file.relative, packingMethod, fileData.length, timeStamp); entry.contents = fileData; entry.dataSize = fileData.length; return entry; }).sort((a, b) => { if (a.packingMethod === b.packingMethod) { return 0; } if (a.packingMethod === packingMethod_1.PackingMethod.packed) { return 1; } //unpacked files first to create a buffer for lzh compression return -1; }); const header = new header_1.Header(extensions, entries); const buf = new pboFormatter_1.PboFormatter().format(header, options); return buf; } } exports.PboBuilder = PboBuilder; //# sourceMappingURL=pboBuilder.js.map