UNPKG

gulp-armapbo

Version:

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

45 lines (43 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const patternMatcher_1 = require("./patternMatcher"); const packingMethod_1 = require("../domain/packingMethod"); class PackingFuncFactory { static getPackingFunc(options) { const compress = options.compress; switch (true) { case (typeof compress === 'string'): { return getMatchByPatterns([compress]); } case (Array.isArray(compress)): { const patterns = compress.filter(s => !!(typeof s === 'string' && s.trim())); if (patterns.length) { return getMatchByPatterns(patterns); } else { return uncompressed; } } default: { return uncompressed; } } } } exports.PackingFuncFactory = PackingFuncFactory; function uncompressed() { return packingMethod_1.PackingMethod.uncompressed; } function getMatchByPatterns(patterns) { const matcher = patternMatcher_1.PatternMatcher.create(patterns); return (file) => { let result = packingMethod_1.PackingMethod.uncompressed; const contents = file.contents; if (contents.length > 0) { const match = matcher.match(file.relative); if (match) { result = packingMethod_1.PackingMethod.packed; } } return result; }; } //# sourceMappingURL=packingFuncFactory.js.map