Skip to content
This repository has been archived by the owner on Dec 2, 2018. It is now read-only.

Commit

Permalink
Pass through full options object.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-eb committed Jan 2, 2015
1 parent a7343b6 commit af1fa90
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,24 @@

'use strict';

var uncss = require('uncss'),
gutil = require('gulp-util'),
transform = require('stream').Transform,
objectAssign = require('object-assign'),
var uncss = require('uncss'),
gutil = require('gulp-util'),
assign = require('object-assign'),
transform = require('stream').Transform,

PLUGIN_NAME = 'gulp-uncss';
PLUGIN_NAME = 'gulp-uncss';

module.exports = function() {
module.exports = function(options) {
var stream = new transform({ objectMode: true });
var options = {
html: arguments[0].html,
ignore: arguments[0].ignore,
timeout: arguments[0].timeout,
ignoreSheets: [/\s*/]
};

// Ignore stylesheets in the HTML files; only use those from the stream
options.ignoreSheets = [/\s*/];

stream._transform = function(file, unused, done) {
if (file.isStream()) {
return done(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
} else if (file.isBuffer()) {
uncss(options.html, objectAssign(options, { raw: String(file.contents) }), function(err, output) {
uncss(options.html, assign(options, { raw: String(file.contents) }), function(err, output) {
if (err) {
return done(new gutil.PluginError(PLUGIN_NAME, err));
}
Expand All @@ -36,4 +33,4 @@ module.exports = function() {
};

return stream;
}
};

0 comments on commit af1fa90

Please sign in to comment.