#!/usr/bin/env node const gjv = require('../'), fs = require('fs'), filenames = process.argv.splice(2); if (filenames.length) { filenames.forEach(filename => { let file; try { file = fs.readFileSync(filename); } catch(e) { console.log('failed to open file: ' + filename); return; } validateGeoJson(file); }); } else { let incomingJson = ''; process.stdin.on('readable', () => { let chunk = process.stdin.read(); if (chunk !== null) { incomingJson += chunk; } }); process.stdin.on('end', function () { validateGeoJson(incomingJson); }); } function validateGeoJson(rawJson) { const json = JSON.parse(rawJson); const t = gjv.valid(json, true); if (t.length) { t.forEach(err => { console.log(err); }); } else { console.log('valid!'); } }