Security update to Drupal 8.4.6
[yaffs-website] / node_modules / uncss / bin / uncss
1 #!/usr/bin/env node
2
3 'use strict';
4
5 (function () {
6     process.title = 'uncss';
7
8     var uncss = require('../src/uncss.js'),
9         data = require('../package.json'),
10         program = require('commander');
11
12     var buffer = '',
13         options;
14
15     function listArg(val) {
16         return val.split(',');
17     }
18
19     program
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>')
31         .parse(process.argv);
32
33     options = {
34         ignore: program.ignore,
35         ignoreSheets: program.ignoreSheets,
36         media: program.media,
37         csspath: program.csspath,
38         stylesheets: program.stylesheets,
39         raw: program.raw,
40         timeout: program.timeout,
41         htmlroot: program.htmlroot,
42         uncssrc: program.uncssrc
43     };
44
45     if (!program.args.length) {
46         /* No files were specified, read HTML from stdin */
47         process.stdin.resume();
48         process.stdin.setEncoding('utf8');
49
50         process.stdin.on('data', function (chunk) {
51             buffer += chunk;
52         });
53
54         process.stdin.on('end', function () {
55             uncss(buffer, options, function (err, css) {
56                 if (err) {
57                     throw err;
58                 }
59                 console.log(css);
60             });
61         });
62     } else {
63         if (options.ignore) {
64             options.ignore = options.ignore.map(function (ign) {
65                 /* Create RegExes */
66                 if (ign[0] === '/') {
67                     /* Remove starting and trailing '/' */
68                     return new RegExp(ign.slice(1, -1));
69                 }
70                 return ign;
71             });
72         }
73
74         if (options.ignoreSheets) {
75             options.ignoreSheets = options.ignoreSheets.map(function (ign) {
76                 /* Create RegExes */
77                 if (ign[0] === '/') {
78                     /* Remove starting and trailing '/' */
79                     return new RegExp(ign.slice(1, -1));
80                 }
81                 return ign;
82             });
83         }
84
85         /* If used from the command line, concatenate the output */
86         uncss(program.args, options, function (err, css) {
87             if (err) {
88                 throw err;
89             }
90             console.log(css);
91         });
92     }
93
94 }());