#!/usr/bin/env node
// Compile a Vega-Lite spec to Vega
const {createWriteStream} = require('fs');const vegaLite = require('..');const compactStringify = require('json-stringify-pretty-compact');const read = require('./read');const args = require('./args');
const arg = args('vega');
// load spec, compile vg specread(arg._[0]).then(text => compile(JSON.parse(text)));
function compile(vlSpec) { // @ts-ignore const vgSpec = vegaLite.compile(vlSpec).spec; const file = arg._[1] || null; const out = file ? createWriteStream(file) : process.stdout; if (arg.p) { out.write(compactStringify(vgSpec) + '\n'); } else { out.write(JSON.stringify(vgSpec) + '\n'); }}