-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
39 lines (33 loc) · 790 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
37
38
39
/* eslint-disable no-console */
const yargs = require('yargs');
const path = require('path');
const run = require('./export');
process.on('unhandledRejection', (e) => {
console.error(e);
throw e;
});
process.on('uncaughtException', (e) => {
console.error(e);
});
const { argv } = yargs
.usage('$0 <source.drawio> -o [target]')
.option('F', {
alias: 'fmt',
describe: 'output format',
type: 'string',
})
.option('o', {
alias: 'output',
demandOption: true,
default: 'a.png',
describe: 'output file',
type: 'string',
});
if (argv._.length !== 1) {
throw new Error('Exactly one file at a time');
}
module.exports = () => run({
file: argv._[0],
format: argv.fmt || path.extname(argv.output).replace(/^\./, ''),
path: argv.output,
});