handow-shm
Version:
E2E test server with Handow engine
1 lines • 1.11 kB
JavaScript
;const e=require("deep-extend"),t=require("path"),r=require("fs"),s=require("../logger");let n=[];const o=(e,s,n,a)=>{try{const c=a?a.split(/\s*,\s*/):[],i=r.readdirSync(e);if(0===i.length)return[];i.forEach(i=>{let l=t.join(`${e}`,`${i}`);"win32"==process.platform.toLowerCase()?l=l.replace(/\\/g,"/"):process.platform.toLowerCase();const p=r.statSync(l);if(p&&p.isDirectory()&&"node_modules"!==i&&-1===c.indexOf(i)&&!i.startsWith(".")){const e={label:`${i}`,path:l,type:"dir",isExpand:!1,branch:[]};n.push(e),o(l,s,e.branch,a)}else if(!p.isDirectory()&&!i.startsWith(".")&&"package.json"!=i&&"package-lock.json"!=i&&!i.endsWith("tree.json"))for(const e of s)if(i.endsWith(e)||"_ALL_"===e){let t;t="feature"===e?"story":"plan.json"===e||"json"===e&&i.endsWith(".plan.json")?"plan":"_ALL_"===e?"":e,n.push({label:`${i}`,path:l,type:t,isExpand:!1,branch:null})}})}catch(e){return[]}},a=e=>{for(let t=0;t<e.length;t++)e[t].branch&&(0==e[t].branch.length?(e.splice(t,1),t-=1):a(e[t].branch))};module.exports=((e,t,r,s)=>{n=[];const c=t.split(/\s*,\s*/);return o(e,c,n,s),"true"!=r&&(a(n),a(n),a(n)),n});