Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env node
const fs = require('fs');
if (!process.argv[2]) {
console.error('Incorrect parameters');
console.error('Usage: ./analytics.js <json-file>');
function main() {
const INPUT_PATH = process.argv[2];
return new Promise((resolve, reject) => {
const rStream = fs.createReadStream(INPUT_PATH, { encoding: 'utf8' });
rStream.on('end', resolve)
rStream.on('error', reject)
rStream.on('data', (data) => {
throw new Error('e');
.catch(err => {
console.error('Error happened:', err)
throw err;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment