Skip to content

hohogpb/traverse_folder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

traverse_folder

npm downloads

traverse folder in js

usage

npm install traverse_folder

or

yarn add traverse_folder
const traverse_folder = require('traverse_folder')
traverse_folder('models');
// or
cosnt items = traverse_folder('models');

or your can add global and use "dirtree" cmd

npm install traverse_folder -g

cmd> dirtree .
├─index.js
├─sequelize.js
├─system
│  ├─sys_dict.js
│  ├─sys_log.js
│  ├─sys_organization.js
│  ├─sys_permission.js
│  ├─sys_role.js
│  ├─sys_role_permission.js
│  ├─sys_user.js
│  ├─sys_user_organization.js
│  └─sys_user_role.js
├─todo
│  ├─dhprj_resource.js
│  ├─dhprj_todo.js
│  ├─dhprj_todo_bug.js
│  ├─dhprj_todo_milestone.js
│  └─dhprj_todo_resource.js
└─wf
   ├─wf_activity.js
   ├─wf_activity_instance.js
   ├─wf_deplyment.js
   ├─wf_form.js
   ├─wf_instance.js
   ├─wf_process.js
   ├─wf_process_instance.js
   ├─wf_process_instance_log.js
   └─wf_process_instance_postponed.js

examples:

const traverse_folder = require('traverse_folder')

// your can
traverse_folder("./");

// or you can
let items = traverse_folder("./");

for (const item of items) {
  const { indentname, filename, filepath } = item;
  console.log(indentname);
}

// or you can
items = traverse_folder("./", [], [],
  (dir, filenames) => {
    return filenames.filter((f) => f == "foo.js");
  },
);

// bla bla bla.....