Skip to content

Commit

Permalink
use dynamic import
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Nov 19, 2024
1 parent 9059240 commit 101bb87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bin/vl2vg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

const {createWriteStream} = require('fs');
const vegaLite = require('..');
const compactStringify = require('json-stringify-pretty-compact');
const read = require('./read');
const args = require('./args');

Expand All @@ -13,13 +12,14 @@ const arg = args('vega');
// load spec, compile vg spec
read(arg._[0]).then(text => compile(JSON.parse(text)));

function compile(vlSpec) {
async 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) {
const compactStringify = (await import('json-stringify-pretty-compact')).default;
out.write(compactStringify(vgSpec) + '\n');
} else {
out.write(JSON.stringify(vgSpec) + '\n');
Expand Down

0 comments on commit 101bb87

Please sign in to comment.