1 | var stream = require("stream");
|
2 | var path = require("path");
|
3 | var util = require("util");
|
4 |
|
5 | util.inherits(Cmify, stream.Transform);
|
6 | function 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 |
|
19 | Cmify.prototype.isCssFile = function (filename) {
|
20 | return this.cssExt.test(filename)
|
21 | }
|
22 |
|
23 | Cmify.prototype._transform = function (buf, enc, callback) {
|
24 |
|
25 | if (!this.isCssFile(this._filename)) {
|
26 | this.push(buf)
|
27 | return callback()
|
28 | }
|
29 |
|
30 | this._data += buf
|
31 | callback()
|
32 | };
|
33 |
|
34 | module.exports = Cmify
|