Skip to content

Instantly share code, notes, and snippets.

@devsnek
Created March 14, 2020 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devsnek/c1fe83211925bedc2969e1084b7fd263 to your computer and use it in GitHub Desktop.
Save devsnek/c1fe83211925bedc2969e1084b7fd263 to your computer and use it in GitHub Desktop.
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