From f6dd3826ad45953203881f49264408ad866aef64 Mon Sep 17 00:00:00 2001 From: Sahil Bansal Date: Sat, 9 May 2020 18:30:49 +0530 Subject: [PATCH] Add good_filepaths function in workflow script --- .github/workflows/script.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/script.js diff --git a/.github/workflows/script.js b/.github/workflows/script.js new file mode 100644 index 000000000..aa2909202 --- /dev/null +++ b/.github/workflows/script.js @@ -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); \ No newline at end of file