Skip to content

pthm/node-path-list-to-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

path-list-to-tree

Converts a list of file paths into a tree structure.

Example

import pathListToTree from 'path-list-to-tree';

const filePaths = [
  '.gitignore',
  'README.md',
  'package.json',
  'src/index.ts',
  'tsconfig.json',
  'yarn-error.log',
  'yarn.lock'
];

console.log(pathListToTree(filePaths))
[
   {
      "name":".gitignore",
      "children":[

      ]
   },
   {
      "name":"README.md",
      "children":[

      ]
   },
   {
      "name":"package.json",
      "children":[

      ]
   },
   {
      "name":"src",
      "children":[
         {
            "name":"index.ts",
            "children":[

            ]
         }
      ]
   },
   {
      "name":"tsconfig.json",
      "children":[

      ]
   },
   {
      "name":"yarn-error.log",
      "children":[

      ]
   },
   {
      "name":"yarn.lock",
      "children":[

      ]
   }

About

Converts a list of file paths into a tree structure.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published