-
Notifications
You must be signed in to change notification settings - Fork 3
/
branch_pip_path.js
41 lines (31 loc) · 1.06 KB
/
branch_pip_path.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// dependencies
const fse = require('fs-extra')
// constants
const PROPOSED_PATH = './Proposed';
const IGNORED_DIRS = ['PIP_TEMPLATE', 'GOVERNANCE_PROPOSAL_TEMPLATE'];
const proposed_paths = [
'Adding_A_Methodology',
];
const path_regex = new RegExp('^.\/Proposed\/(' + proposed_paths.join('|') + ')\/(Step_[1-3])\/([a-z0-9\-\_]+)\/README.md', 'i');
async function main() {
// detect all status.json files
const get_readme_files = function (path, files) {
fse.readdirSync(path).forEach((file) => {
let subpath = path + '/' + file;
if (!IGNORED_DIRS.includes(file) && fse.lstatSync(subpath).isDirectory()) {
files = get_readme_files(subpath, files);
} else {
let readme_test = subpath.match(path_regex);
if (readme_test) {
files.push(readme_test);
}
}
});
return files;
}
// now, let's scan the 3 primary paths
const found_readme = get_readme_files(PROPOSED_PATH, []);
// let's output for use
console.log('%s', (found_readme.length > 0) ? found_readme[0][1] + '/' + found_readme[0][2] + '/' + found_readme[0][3] : '');
}
main();