This commit is contained in:
Sindre Sorhus 2014-08-19 01:14:43 +02:00
parent 1c2aacc7ce
commit 8f10b458e8
5 changed files with 26 additions and 25 deletions

View File

@ -1,4 +1,3 @@
# editorconfig.org
root = true root = true
[*] [*]

View File

@ -4,16 +4,10 @@
"bitwise": true, "bitwise": true,
"camelcase": true, "camelcase": true,
"curly": true, "curly": true,
"eqeqeq": true,
"immed": true, "immed": true,
"indent": 4,
"newcap": true, "newcap": true,
"noarg": true, "noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true, "undef": true,
"unused": true, "unused": "vars",
"strict": true, "strict": true
"trailing": true,
"smarttabs": true
} }

19
cli.js
View File

@ -1,22 +1,25 @@
#!/usr/bin/env node #!/usr/bin/env node
'use strict'; 'use strict';
var pkg = require('./package.json'); var pkg = require('./package.json');
var githubMarkdownCss = require('./index'); var githubMarkdownCss = require('./');
var input = process.argv[2]; var argv = process.argv.slice(2);
function help() { function help() {
console.log(pkg.description); console.log([
console.log(''); '',
console.log('Usage'); ' ' + pkg.description,
console.log(' $ github-markdown-css > <filename>'); '',
' Usage',
' github-markdown-css > <filename>'
].join('\n'));
} }
if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) { if (argv.indexOf('--help') !== -1) {
help(); help();
return; return;
} }
if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) { if (argv.indexOf('--version') !== -1) {
console.log(pkg.version); console.log(pkg.version);
return; return;
} }

View File

@ -6,7 +6,8 @@ var uncss = require('uncss');
function getCss(cb) { function getCss(cb) {
got('https://github.com', function (err, data) { got('https://github.com', function (err, data) {
if (err) { if (err) {
return cb(err); cb(err);
return;
} }
var ret = []; var ret = [];
@ -17,7 +18,8 @@ function getCss(cb) {
}); });
if (ret.length === 0) { if (ret.length === 0) {
return cb(new Error('Could not find GitHub stylesheets')); cb(new Error('Could not find GitHub stylesheets'));
return;
} }
cb(null, ret); cb(null, ret);
@ -29,7 +31,8 @@ function getRenderedFixture(cb) {
got(url, function (err, data) { got(url, function (err, data) {
if (err) { if (err) {
return cb(err); cb(err);
return;
} }
var $ = cheerio.load(data); var $ = cheerio.load(data);
@ -103,12 +106,14 @@ function cleanupCss(str) {
module.exports = function (cb) { module.exports = function (cb) {
getRenderedFixture(function (err, html) { getRenderedFixture(function (err, html) {
if (err) { if (err) {
return cb(err); cb(err);
return;
} }
getCss(function (err, stylesheets) { getCss(function (err, stylesheets) {
if (err) { if (err) {
return cb(err); cb(err);
return;
} }
uncss(html, { uncss(html, {

View File

@ -4,14 +4,14 @@
"description": "The minimal amount of CSS to replicate the GitHub Markdown style", "description": "The minimal amount of CSS to replicate the GitHub Markdown style",
"license": "MIT", "license": "MIT",
"repository": "sindresorhus/github-markdown-css", "repository": "sindresorhus/github-markdown-css",
"bin": {
"github-markdown-css": "cli.js"
},
"author": { "author": {
"name": "Sindre Sorhus", "name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com", "email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com" "url": "http://sindresorhus.com"
}, },
"bin": {
"github-markdown-css": "cli.js"
},
"contributors": [ "contributors": [
{ {
"name": "Benjamin Tan", "name": "Benjamin Tan",