gulp-concatenate
Version:
concatenate files like cat command
42 lines (30 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _stream = require("stream");
var _vinyl = require("vinyl");
var _vinyl2 = _interopRequireDefault(_vinyl);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Concat extends _stream.Transform {
constructor(fileName) {
super({ objectMode: true });
this.data = Buffer.from("");
this.fileName = fileName;
}
// $FlowIgnore: Gulp uses object-mode but the flow-typed doesn't respect it, so I suppress warning.
_transform(chunk, encoding, callback) {
this.data = Buffer.concat([this.data, chunk.contents]);
callback();
}
_flush(callback) {
// $FlowIgnore: Gulp uses object-mode but the default node.js flow type doesn't respect it, so I suppress warning.
this.push(new _vinyl2.default({
cwd: process.cwd(),
path: this.fileName,
contents: this.data
}));
callback();
}
}
exports.default = fileName => new Concat(fileName);