6 process.title = 'uncss';
8 var uncss = require('../src/uncss.js'),
9 data = require('../package.json'),
10 program = require('commander');
15 function listArg(val) {
16 return val.split(',');
20 .version(data.version)
21 .usage('[options] <file or URL, ...>\n\t e.g. uncss http://getbootstrap.com/examples/jumbotron/ > stylesheet.css')
22 .option('-i, --ignore <selector, ...>', 'Do not remove given selectors', listArg)
23 .option('-m, --media <media_query, ...>', 'Process additional media queries', listArg)
24 .option('-C, --csspath <path>', 'Relative path where the CSS files are located')
25 .option('-s, --stylesheets <file, ...>', 'Specify additional stylesheets to process', listArg)
26 .option('-S, --ignoreSheets <selector, ...>', 'Do not include specified stylesheets', listArg)
27 .option('-r, --raw <string>', 'Pass in a raw string of CSS')
28 .option('-t, --timeout <milliseconds>', 'Wait for JS evaluation')
29 .option('-H, --htmlroot <folder>', 'Absolute paths\' root location')
30 .option('-u, --uncssrc <file>', 'Load these options from <file>')
34 ignore: program.ignore,
35 ignoreSheets: program.ignoreSheets,
37 csspath: program.csspath,
38 stylesheets: program.stylesheets,
40 timeout: program.timeout,
41 htmlroot: program.htmlroot,
42 uncssrc: program.uncssrc
45 if (!program.args.length) {
46 /* No files were specified, read HTML from stdin */
47 process.stdin.resume();
48 process.stdin.setEncoding('utf8');
50 process.stdin.on('data', function (chunk) {
54 process.stdin.on('end', function () {
55 uncss(buffer, options, function (err, css) {
64 options.ignore = options.ignore.map(function (ign) {
67 /* Remove starting and trailing '/' */
68 return new RegExp(ign.slice(1, -1));
74 if (options.ignoreSheets) {
75 options.ignoreSheets = options.ignoreSheets.map(function (ign) {
78 /* Remove starting and trailing '/' */
79 return new RegExp(ign.slice(1, -1));
85 /* If used from the command line, concatenate the output */
86 uncss(program.args, options, function (err, css) {