Skip to content

Instantly share code, notes, and snippets.

@andrit
Created August 31, 2018 14:54
Show Gist options
  • Save andrit/274fa714164409b11b49cf89154c7c52 to your computer and use it in GitHub Desktop.
Save andrit/274fa714164409b11b49cf89154c7c52 to your computer and use it in GitHub Desktop.
const fs = require(‘fs’).promises;
async function cat(filenmz) {
  for (var filenm of filenmz) {
    let data = await fs.readFile(filenm, ‘utf8’);
    await new Promise((resolve, reject) => {
      process.stdout.write(data, ‘utf8’, (err) => {
        if (err) reject(err);
        else resolve();
      });
    });
  }
}
cat(process.argv.slice(2)).catch(err => { 
    console.error(err.stack); 
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment