mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
Add good_filepaths function in workflow script
This commit is contained in:
36
.github/workflows/script.js
vendored
Normal file
36
.github/workflows/script.js
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// requiring path and fs modules
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
let URL_BASE = "https://github.com/TheAlgorithms/Javascript/blob/master";
|
||||
let g_output = [];
|
||||
|
||||
let filepaths = [];
|
||||
function good_filepaths(top_dir = ".") {
|
||||
fs.readdir(top_dir, function(err, list) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
list.forEach(function(file) {
|
||||
let path = top_dir + "/" + file;
|
||||
if (!file.startsWith(".")) {
|
||||
fs.stat(path, function(err, stat) {
|
||||
if (stat && stat.isDirectory()) {
|
||||
good_filepaths(path);
|
||||
} else {
|
||||
if (file.toLowerCase().endsWith(".js")) {
|
||||
filepaths.push(path.slice(2));
|
||||
// console.log(filepaths);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
good_filepaths();
|
||||
setTimeout(() => {
|
||||
console.log(filepaths.length);
|
||||
}, 1000);
|
Reference in New Issue
Block a user