#!/opt/local/bin/node

// Render a Vega-Lite specification to PNG, using node canvas
import {createWriteStream} from 'fs';
import {render} from './render.js';

render('png', (canvas, arg) => {
  const file = arg._[1] || null;
  const out = file ? createWriteStream(file) : process.stdout;
  const stream = canvas.createPNGStream({resolution: arg.ppi || undefined});
  stream.on('data', (chunk) => {
    out.write(chunk);
  });
});
