Skip to content

Instantly share code, notes, and snippets.

@Skitionek
Created April 19, 2019 13:46
Show Gist options
  • Save Skitionek/f0ff67da6bf391ed58eea2fd68c49d0a to your computer and use it in GitHub Desktop.
Save Skitionek/f0ff67da6bf391ed58eea2fd68c49d0a to your computer and use it in GitHub Desktop.
const { spawn } = require('child_process');
const args = process.argv.slice(2);
const child = spawn('tree',['-f', '--', args[0] || '.']);
child.stdout.setEncoding('utf8');
child.stdout.on('data', (chunk) => {
const lines = chunk.split(/\n/g).filter(line=>line!==''&&!line.match(/^\d/));
lines.forEach(line=>console.log(line.replace(/([^ \n]*?)([^ /\n]*)$/,'[$2]($1$2)')));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment