-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
executable file
·49 lines (40 loc) · 1.09 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/env node
const chalk = require('chalk')
var mime = require('mime-types')
var path = require('path');
var parseFile = require('./lib/parseFile.js');
var parseJPEG = require('./lib/parseJPEG.js');
var argPaths = []
function addPath(value) {
return argPaths.push(value);
}
// program options...
const { program } = require('commander')
program.version('0.0.1');
program
.option('-d, --debug', 'Enable debugging options')
.argument('<path...>', 'file paths to be processed', addPath, 0)
// parse the command line!
program.parse(process.argv)
const options = program.opts();
const args = program.args;
// console.log('Options: ', options);
// console.log('Paths: ', argPaths);
// console.log('Remaining arguments: ', args);
if ( argPaths.length > 0 ) {
argPaths.forEach(p => {
console.log( chalk.bold(`Processing ${p}`) )
mType = mime.lookup(p);
if ( mType ) { // valid mime type
if ( mType == "image/jpeg" ) {
console.log( chalk.red.bold(`Found JPEG!`) );
parseJPEG(p)
}
} else {
fExt = path.extname(p);
if ( fExt == ".jumbf" ) {
parseFile(p)
}
}
});
}