Skip to content
Snippets Groups Projects
Commit 7a162312 authored by Alvaro Cabrera Durán's avatar Alvaro Cabrera Durán
Browse files

Dist for dev; add gen.js for CLI

parent 2fba717f
Branches
Tags
No related merge requests found
#!/usr/bin/env node
const jsf = require('../dist/bundle.umd.min.js');
// FIXME: load faker/change on startup?
const sample = process.argv.slice(2)[0];
const { inspect } = require('util');
const { Transform } = require('stream');
const { readFileSync } = require('fs');
const pretty = process.argv.indexOf('--pretty') !== -1;
const noColor = process.argv.indexOf('--no-color') !== -1;
function generate(schema, callback) {
jsf.resolve(JSON.parse(schema)).then(result => {
let sample;
if (pretty) {
sample = inspect(result, { colors: !noColor, depth: Infinity });
} else {
sample = JSON.stringify(result);
}
callback(null, `${sample}\n`);
});
}
process.stdin.pipe(new Transform({
transform(entry, enc, callback) {
generate(Buffer.from(entry, enc).toString(), callback);
}
})).pipe(process.stdout);
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -3,6 +3,9 @@
"version": "0.5.0-rc17",
"description": "JSON-Schema + fake data generators",
"homepage": "http://json-schema-faker.js.org",
"bin": {
"jsf": "./bin/gen.js"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"unpkg": "dist/bundle.umd.min.js",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment