Comparing version 0.4.3 to 0.4.4
#!/usr/bin/env node | ||
var uncss = require('../lib/uncss.js'), | ||
utility = require('../lib/utility.js'), | ||
program = require('commander'), | ||
buffer = ''; | ||
arg, | ||
argv, | ||
buffer = '', | ||
callback, | ||
compress, | ||
files = [], | ||
i, | ||
options = {}; | ||
program | ||
.version('0.4.4') | ||
.usage('[options] <file ...>') | ||
.option('-c, --compress', 'Compress CSS output') | ||
.parse(process.argv); | ||
/* Parse command line options */ | ||
argv = process.argv.splice(2); | ||
for (i = 0; i < argv.length; i++) { | ||
arg = argv[i]; | ||
if (arg.length < 2) { | ||
console.log('Unrecognized token: ' + arg); | ||
process.exit(); | ||
} | ||
if (arg[0] === '-') { | ||
options[arg[1]] = true; | ||
} else { | ||
files.push(arg); | ||
} | ||
} | ||
if (options.h) { | ||
utility.showHelp(); | ||
process.exit(); | ||
} | ||
if (options.c) { | ||
options.compress = true; | ||
} else { | ||
options.compress = false; | ||
} | ||
if (files.length === 0) { | ||
if (program.args.length === 0) { | ||
// No files were specified, read html from stdin | ||
process.stdin.resume(); | ||
@@ -50,10 +23,11 @@ process.stdin.setEncoding('utf8'); | ||
process.stdin.on('end', function() { | ||
uncss(buffer, options, function (uncss) { | ||
uncss(buffer, program.options, function (uncss) { | ||
console.log(uncss); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
uncss(files, options, function (uncss) { | ||
uncss(program.args, program.options, function (uncss) { | ||
console.log(uncss); | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -6,12 +6,4 @@ /*jslint node: true, plusplus: true, stupid: true */ | ||
var fs = require('fs'), | ||
soupselect = require('soupselect').select, | ||
soupselect = require('soupselect').select; | ||
help = ' ' + '\n' + | ||
' uncss [options] <file.html file.css ...>' + '\n' + | ||
' ' + '\n' + | ||
' Options:' + '\n' + | ||
' ' + '\n' + | ||
' -h, --help output help message' + '\n' + | ||
' -c, --compress compress css'; | ||
/** | ||
@@ -22,3 +14,3 @@ * Given an array of filenames, return an array of the files' contents, | ||
* @return {Array} Array Of the files' contents | ||
* @todo use async methods | ||
* @TODO use async methods | ||
*/ | ||
@@ -76,11 +68,3 @@ function mapReadFiles(files) { | ||
/** | ||
* Show help string | ||
*/ | ||
function showHelp() { | ||
console.log(help); | ||
} | ||
module.exports.mapReadFiles = mapReadFiles; | ||
module.exports.filterUnusedRules = filterUnusedRules; | ||
module.exports.showHelp = showHelp; |
{ | ||
"name": "uncss", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Remove unused CSS styles", | ||
@@ -33,4 +33,5 @@ "main": "lib/uncss.js", | ||
"htmlparser2": ">= 3.0.5", | ||
"soupselect": ">= 0.2.0" | ||
"soupselect": ">= 0.2.0", | ||
"commander": "~2.0.0" | ||
} | ||
} |
182037
10
7257
5
+ Addedcommander@~2.0.0
+ Addedcommander@2.0.0(transitive)