Created
April 19, 2019 13:46
-
-
Save Skitionek/f0ff67da6bf391ed58eea2fd68c49d0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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