-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
45 lines (40 loc) · 1.1 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env node
var minimist = require('minimist')
var argv = minimist(process.argv.slice(2), {
boolean: [
'help',
'versions'
],
alias: {
c: 'compress',
h: 'help',
V: 'versions'
}
})
var pkg = require('./package.json')
var fs = require('fs')
var Atcss = require('./')
if (argv.V) console.log(pkg.version)
if (argv.h) {
console.log('Usage: atcss input-name output-name [options]');
console.log('');
console.log('Options:');
console.log('');
console.log(' -c, --compress use output compression');
console.log(' -V, --versions output the version number');
console.log(' -h, --help output usage information');
}
if (argv._[0] && argv._[1]) {
var input = argv._[0]
var output = argv._[1]
var compress = false
if (argv.c) compress = true
var options = {}
options.compress = compress
var css = fs.readFileSync(input, 'utf-8')
var atcss = new Atcss(css, options)
fs.writeFile(output, atcss.process(css), function (err) {
if (err) throw err
console.log('Processed')
})
}