Skip to content

Instantly share code, notes, and snippets.

@blackmiaool
Created March 14, 2017 03:15
Show Gist options
  • Save blackmiaool/1c3b7d73ebcbf9a9e9b704a62c51873f to your computer and use it in GitHub Desktop.
Save blackmiaool/1c3b7d73ebcbf9a9e9b704a62c51873f to your computer and use it in GitHub Desktop.
get js file list
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