8000 don't need to write to disk anymore · akoenig/github-markdown-css@672d44b · GitHub
[go: up one dir, main page]

Skip to content

Commit 672d44b

Browse files
committed
don't need to write to disk anymore
UnCSS now accepts an HTML string as input
1 parent bfa19de commit 672d44b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
var got = require('got');
33
var cheerio = require('cheerio');
44
var uncss = require('uncss');
5-
var tempWrite = require('temp-write');
65

76
function getCss(cb) {
87
got('https://github.com', function (err, data) {
@@ -26,14 +25,17 @@ function getCss(cb) {
2625
}
2726

2827
function getRenderedFixture(cb) {
29-
got('https://github.com/sindresorhus/github-markdown-css/blob/gh-pages/fixture.md', function (err, data) {
28+
var url = 'https://github.com/sindresorhus/github-markdown-css/blob/gh-pages/fixture.md';
29+
30+
got(url, function (err, data) {
3031
if (err) {
3132
return cb(err);
3233
}
3334

3435
var $ = cheerio.load(data);
36+
var html = $('.markdown-body').parent().html();
3537

36-
cb(null, tempWrite.sync($('.markdown-body').parent().html()));
38+
cb(null, html);
3739
});
3840
}
3941

@@ -99,7 +101,7 @@ function cleanupCss(str) {
99101
}
100102

101103
module.exports = function (cb) {
102-
getRenderedFixture(function (err, fixture) {
104+
getRenderedFixture(function (err, html) {
103105
if (err) {
104106
return cb(err);
105107
}
@@ -109,7 +111,7 @@ module.exports = function (cb) {
109111
return cb(err);
110112
}
111113

112-
uncss([fixture], {
114+
uncss(html, {
113115
stylesheets: stylesheets,
114116
ignore: [/^\.highlight/]
115117
}, function (err, css) {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
"dependencies": {
4545
"cheerio": "^0.17.0",
4646
"css": "^2.0.0",
47-
"got": "^0.3.0",
48-
"temp-write": "^0.3.1",
47+
"got": "^1.0.0",
4948
"uncss": "^0.8.3"
5049
},
5150
"devDependencies": {

0 commit comments

Comments
 (0)
0