-
Notifications
You must be signed in to change notification settings - Fork 0
/
2leo.js
executable file
·63 lines (52 loc) · 1.54 KB
/
2leo.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
50
51
52
53
54
55
56
57
58
59
60
61
#!/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 xml files to leo format. Converts all xml files in
input folder into leo files in output folder.
Required parameters:
indir: the folder where the input xml files are
outdir: the folder you want the output files to go into
xslfile: the xsl file that specifies the transformation rules
Usage: node 2leo.js indir outdir xslfile
Or, to run at command line, check first line of 2leo.js and
then run ./2leo.js indir outdir
Options:
--help: this message
`);
process.exit(0);
}
var indir = (argv._[0]);
if (! indir){
console.log("\n=== No input folder specified! More info about this program:");
displayHelp();
process.exit(0);
}
var outdir = (argv._[1]);
if (! outdir ){
console.log("\n=== No output folder specified! More info about this program:");
displayHelp();
process.exit(0);
}
var xslfile = (argv._[2]);
if (! xslfile ){
console.log("\n=== No input folder specified! More info about this program:");
displayHelp();
process.exit(0);
}
var converter = new Converter(argv);
fs.stat(indir, (err, stat) => {
if(err == null) {
converter.init(xslfile).then(() => {
converter.importFolder(indir, outdir);
})
} else {
console.log('Invalid input folder: ' + '\n\n', err);
process.exit();
}
});