UNPKG

gulp-armapbo

Version:

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

39 lines (37 loc) 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const stream_1 = require("stream"); const pboBuilder_1 = require("./pboBuilder"); const path = require("path"); const File = require("vinyl"); class PboTransformStream extends stream_1.Transform { constructor(options) { super({ objectMode: true }); this._contentParts = []; this._builder = new pboBuilder_1.PboBuilder(); this._options = options || {}; } _transform(file, enc, cb) { if (file.isStream()) { cb(new Error('Streaming input is not supported')); return; } this._contentParts.push(file); cb(); } _flush(cb) { const data = this._builder.build(this._contentParts, this._options); const fileName = this._options.fileName || this._getDefaultName(); const result = new File({ path: fileName, contents: data }); this.push(result); cb(); } _getDefaultName() { const cwd = process.cwd(); const segments = cwd.split(path.sep); const name = `${segments[segments.length - 1]}.pbo`; return name; } } exports.PboTransformStream = PboTransformStream; //# sourceMappingURL=pboTransformStream.js.map