1 | #!/usr/bin/env node
|
2 |
|
3 | // builtin
|
4 | var fs = require('fs');
|
5 | var path = require('path');
|
6 |
|
7 | // local
|
8 | var npmcss = require('..');
|
9 |
|
10 | var optimist = require('optimist')
|
11 | .usage('Usage: npm-css [entry file] {OPTIONS}')
|
12 | .wrap(80)
|
13 | .option('outfile', {
|
14 | alias: 'o',
|
15 | desc: 'Write the bundled css to this file\n' +
|
16 | 'If unspecified the output will go to stdout'
|
17 | })
|
18 |
|
19 | var argv = optimist.argv;
|
20 |
|
21 | var files = argv._;
|
22 |
|
23 | if (!files || files.length === 0) {
|
24 | console.error('Error: at least one entry file must be specified\n');
|
25 | optimist.showHelp();
|
26 | return;
|
27 | }
|
28 |
|
29 | var css = '';
|
30 |
|
31 | files.forEach(function(file) {
|
32 | file = path.resolve(process.cwd(), file);
|
33 | css += npmcss(file);
|
34 | });
|
35 |
|
36 | if (argv.outfile) {
|
37 | fs.writeFileSync(argv.outfile, css, 'utf8');
|
38 | return;
|
39 | }
|
40 |
|
41 | process.stdout.write(css);
|