()
| 15 | const sourceHelpers = require('./source_helpers.js'); |
| 16 | |
| 17 | function main() { |
| 18 | Error.stackTraceLimit = Infinity; |
| 19 | |
| 20 | program |
| 21 | .version('0.0.1') |
| 22 | .option('-i, --input_dir <path>', 'Input directory.') |
| 23 | .option('-o, --output_dir <path>', 'Output directory.') |
| 24 | .parse(process.argv); |
| 25 | |
| 26 | if (!program.args.length) { |
| 27 | console.log('Need to specify corpora.'); |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | if (!program.output_dir) { |
| 32 | console.log('Need to specify output dir.'); |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | const mutateDb = new db.MutateDbWriter(program.output_dir); |
| 37 | |
| 38 | const inputDir = path.resolve(program.input_dir); |
| 39 | for (const corpusName of program.args) { |
| 40 | const curCorpus = corpus.create(inputDir, corpusName); |
| 41 | for (const relPath of curCorpus.relFiles()) { |
| 42 | let source; |
| 43 | try { |
| 44 | source = sourceHelpers.loadSource(curCorpus, relPath); |
| 45 | } catch (e) { |
| 46 | console.log(e); |
| 47 | continue; |
| 48 | } |
| 49 | |
| 50 | if (!source) { |
| 51 | continue; |
| 52 | } |
| 53 | |
| 54 | try{ |
| 55 | mutateDb.process(source); |
| 56 | } catch (e) { |
| 57 | console.log(e); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | mutateDb.writeIndex(); |
| 63 | } |
| 64 | |
| 65 | main(); |
no test coverage detected