Created
March 14, 2017 03:15
-
-
Save blackmiaool/1c3b7d73ebcbf9a9e9b704a62c51873f to your computer and use it in GitHub Desktop.
get js file list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const treeify = require('file-tree-sync'); | |
const fs=require('fs'); | |
const linearData = []; | |
const ret = []; | |
const childKey = "files"; | |
function getLinearData(arr, position) { | |
arr.forEach(function (obj, index) { | |
const pos = position.concat([index]); | |
if (obj[childKey] && obj[childKey].length) { | |
const children = obj[childKey]; | |
obj[childKey] = []; | |
getLinearData(children, pos); | |
} else { | |
if (obj.fullpath.match(/^\.git/)) { | |
return; | |
} | |
if (obj.fullpath.match(/^node_modules/)) { | |
return; | |
} | |
if (obj.name.match(/\.jsx?$/)) { | |
linearData.push(obj); | |
} | |
} | |
}); | |
} | |
getLinearData(treeify("."), []); | |
fs.writeFileSync("out",linearData.map(o => o.fullpath).join('\n')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment