mirror of
https://github.com/tenrok/BBob.git
synced 2026-05-15 11:59:37 +03:00
26 lines
591 B
JavaScript
26 lines
591 B
JavaScript
const fs = require('fs');
|
|
const program = require('commander');
|
|
const { version } = require('../package.json');
|
|
|
|
program
|
|
.version(version)
|
|
.parse(process.argv);
|
|
|
|
const options = {};
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
function readFile(filename, encoding, callback) {
|
|
if (options.file === '-') {
|
|
// read from stdin
|
|
const chunks = [];
|
|
|
|
process.stdin.on('data', (chunk) => {
|
|
chunks.push(chunk);
|
|
});
|
|
|
|
process.stdin.on('end', () => callback(null, Buffer.concat(chunks).toString(encoding)));
|
|
} else {
|
|
fs.readFile(filename, encoding, callback);
|
|
}
|
|
}
|