-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·36 lines (33 loc) · 947 Bytes
/
index.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
#!/usr/bin/env node
/**
* CLI
*/
var
program = require('commander'),
CSSDataURI = require('./lib/css-datauri');
program
.version('0.0.1')
.arguments('<src> <dest>')
.option('-f, --filter <string>', 'Filter assets by glob pattern')
.option('-b, --base <string>', 'Specify asset path')
.action(function(src, dest, program) {
CSSDataURI.promise(program.args[0], program.args[1], (function (program) {
// Get cli options
var
result = {};
keys = program.options.map( function (option) { return option.long.replace(/^-+/, "")});
Object.keys(program)
.filter( function (key) { return keys.indexOf(key) >= 0; })
.forEach( function(key) {
result[key] = program[key];
});
return result;
})(program))
.then(function () {
// Success
}).catch( function (err) { throw(err); });
})
.parse(process.argv);
if(!program.args.length) {
program.help();
}