MIRROR: javascript for 🐜's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 33 lines 737 B view raw
1function cleanup() { 2 try { process.stdin.setRawMode(false); } catch {} 3 try { process.stdin.pause(); } catch {} 4} 5 6if (!process.stdin.isTTY || typeof process.stdin.setRawMode !== 'function') { 7 console.log('SKIP'); 8 process.exit(0); 9} 10 11process.stdin.setRawMode(true); 12process.stdin.setEncoding('utf8'); 13process.stdin.resume(); 14process.stdout.write('READY\n'); 15 16const timeout = setTimeout(() => { 17 cleanup(); 18 console.log('TIMEOUT'); 19 process.exit(3); 20}, 2000); 21 22process.stdin.on('data', chunk => { 23 clearTimeout(timeout); 24 cleanup(); 25 26 if (typeof chunk !== 'string') { 27 console.log('TYPE', typeof chunk); 28 process.exit(4); 29 } 30 31 console.log('DATA', JSON.stringify(chunk)); 32 process.exit(chunk === 'A€' ? 0 : 5); 33});