-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (21 loc) · 657 Bytes
/
index.js
File metadata and controls
27 lines (21 loc) · 657 Bytes
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
"use strict";
const docRand = require('./doc-rand.js');
const nco = require('nco');
const fs = require('fs');
const args = process.argv.slice(2);
const inputFile = nco(args[0], null);
const outputCount = nco(args[1], 0);
const outputFile = nco(args[2], null)
if(inputFile === null) {
throw "Input file path not specified.";
}
if(outputFile === null) {
throw "Input file path not specified.";
}
const doc = docRand.fromFile(inputFile, outputCount);
fs.writeFile(outputFile, JSON.stringify(doc, null, 2), function(err) {
if(err) {
return console.log(err);
}
console.log(`Created ${outputCount} random json documents in ${outputFile}`)
});