From 337f3c2abc757c59f8119ead8d48c956cf7cfc65 Mon Sep 17 00:00:00 2001 From: Sahil Bansal Date: Sat, 9 May 2020 19:22:01 +0530 Subject: [PATCH] Add md_prefix and print_path functions --- .github/workflows/script.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/script.js b/.github/workflows/script.js index aa2909202..fd2dff808 100644 --- a/.github/workflows/script.js +++ b/.github/workflows/script.js @@ -30,7 +30,31 @@ function good_filepaths(top_dir = ".") { }) } +function md_prefix(i) { + if (i) { + let res = ' '.repeat(i); + return res + "*"; + } else { + return "\n##" + } +} + +function print_path(old_path, new_path) { + let old_parts = old_path.split(path.sep); + let new_parts = new_path.split(path.sep); + for (let i = 0; i < new_parts.length; ++i) { + let new_part = new_parts[i]; + if (i + 1 > old_parts.len || old_parts[i] != new_part) { + if (new_part) { + g_output.push(`${md_prefix(i)} ${new_part.replace('_', ' ')}`); + // console.log(`${md_prefix(i)} ${new_part.replace('_', ' ')}`); + } + } + } + return new_path; +} + good_filepaths(); setTimeout(() => { - console.log(filepaths.length); + console.log(filepaths); }, 1000); \ No newline at end of file