don't need to write to disk anymore

UnCSS now accepts an HTML string as input
This commit is contained in:
Sindre Sorhus 2014-08-08 10:00:19 +02:00
parent bfa19de865
commit 672d44b98a
2 changed files with 8 additions and 7 deletions

View File

@ -2,7 +2,6 @@
var got = require('got'); var got = require('got');
var cheerio = require('cheerio'); var cheerio = require('cheerio');
var uncss = require('uncss'); var uncss = require('uncss');
var tempWrite = require('temp-write');
function getCss(cb) { function getCss(cb) {
got('https://github.com', function (err, data) { got('https://github.com', function (err, data) {
@ -26,14 +25,17 @@ function getCss(cb) {
} }
function getRenderedFixture(cb) { function getRenderedFixture(cb) {
got('https://github.com/sindresorhus/github-markdown-css/blob/gh-pages/fixture.md', function (err, data) { var url = 'https://github.com/sindresorhus/github-markdown-css/blob/gh-pages/fixture.md';
got(url, function (err, data) {
if (err) { if (err) {
return cb(err); return cb(err);
} }
var $ = cheerio.load(data); var $ = cheerio.load(data);
var html = $('.markdown-body').parent().html();
cb(null, tempWrite.sync($('.markdown-body').parent().html())); cb(null, html);
}); });
} }
@ -99,7 +101,7 @@ function cleanupCss(str) {
} }
module.exports = function (cb) { module.exports = function (cb) {
getRenderedFixture(function (err, fixture) { getRenderedFixture(function (err, html) {
if (err) { if (err) {
return cb(err); return cb(err);
} }
@ -109,7 +111,7 @@ module.exports = function (cb) {
return cb(err); return cb(err);
} }
uncss([fixture], { uncss(html, {
stylesheets: stylesheets, stylesheets: stylesheets,
ignore: [/^\.highlight/] ignore: [/^\.highlight/]
}, function (err, css) { }, function (err, css) {

View File

@ -44,8 +44,7 @@
"dependencies": { "dependencies": {
"cheerio": "^0.17.0", "cheerio": "^0.17.0",
"css": "^2.0.0", "css": "^2.0.0",
"got": "^0.3.0", "got": "^1.0.0",
"temp-write": "^0.3.1",
"uncss": "^0.8.3" "uncss": "^0.8.3"
}, },
"devDependencies": { "devDependencies": {