Created
March 14, 2020 00:31
-
-
Save devsnek/c1fe83211925bedc2969e1084b7fd263 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 path = require('path'); | |
let longestLine = ''; | |
const queue = ['./src']; | |
while (queue.length) { | |
const dir = queue.shift(); | |
const files = fs.readdirSync(dir, { withFileTypes: true }); | |
files.forEach((f) => { | |
const name = path.join(dir, f.name); | |
if (f.isDirectory()) { | |
queue.push(name); | |
} else { | |
fs.readFileSync(name, 'utf8') | |
.split('\n') | |
.forEach((line) => { | |
if (line.length > longestLine.length) { | |
longestLine = line; | |
} | |
}); | |
} | |
}); | |
} | |
console.log(longestLine); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment