#!/usr/bin/env node
// Render a Vega specification to PNG, using node canvas
const {createWriteStream} = require('fs'),
      render = require('../src/render');

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