UNPKG

719 BJavaScriptView Raw
1var stream = require("stream");
2var path = require("path");
3var util = require("util");
4
5util.inherits(Cmify, stream.Transform);
6function Cmify(filename, opts) {
7 if (!(this instanceof Cmify)) {
8 return new Cmify(filename, opts);
9 }
10
11 stream.Transform.call(this);
12
13 this.cssExt = /\.css$/;
14 this._data = "";
15 this._filename = filename;
16 this._cssOutFilename = opts.cssOutFilename;
17}
18
19Cmify.prototype.isCssFile = function (filename) {
20 return this.cssExt.test(filename)
21}
22
23Cmify.prototype._transform = function (buf, enc, callback) {
24 // only handle .css files
25 if (!this.isCssFile(this._filename)) {
26 this.push(buf)
27 return callback()
28 }
29
30 this._data += buf
31 callback()
32};
33
34module.exports = Cmify