-
Notifications
You must be signed in to change notification settings - Fork 2
/
w2j.js
executable file
·47 lines (37 loc) · 1.08 KB
/
w2j.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/local/bin/node
var Converter = require('./import');
var fs = require('fs');
var argv = require('minimist')(process.argv.slice(2));
if (argv.help){
displayHelp();
}
function displayHelp(){
console.log(`
Script to convert docx to json.
Usage: node w2j.js input/myfile.docx
Or, to run at command line, check first line of w2j.js and
then run ./w2j.js path_to_file
Options:
--help: this message
--no_cleanup: don't delete intermediate files in output directory
--outdir=path/to/output: output directory, default is 'output'
--datauri: if true, convert image files to inline data
--md: make md output file
`);
process.exit(0);
}
var path = (argv._[0]);
if (! path){
console.log("\n=== No path specified! More info about this program:");
displayHelp();
process.exit(0);
}
var converter = new Converter(argv);
fs.stat(path, (err, stat) => {
if(err == null) {
converter.import(path, argv.outdir);
} else {
console.log('Invalid file path: ' + path + '\n\n', err);
process.exit();
}
});