3.1.3 • Published 2 years ago

recursive-file-walker v3.1.3

Weekly downloads
36
License
MIT
Repository
github
Last release
2 years ago

recursive-file-walker

recursively look over all the files and sub directories from a starting directory

usage

npm i recursive-file-walker

or

npm i -D recursive-file-walker

import fileWalker from "recursive-file-walker";

const response = await fileWalker({
	id: 789,                           // pass an id, if you are using more than one fileWalker function (optional)
  entry: "path/to/start/directory",  // where to start the recursive file walker
  ignoreFiles: ["*.js", "foo/*.js"], // TODO will ignore files (string), or array of file types/paths
	ignoreDirectories: ["bar", "foo"], // TODO will ignore a directory (string), or array of directories
	ignoreDotFiles: true,              // will ignore dotfiles, default:true
  ignoreDotDirectories: true,        // TODO will ignore dotDirectories, default:true 
	readFiles: "modified",             // "true" - all files, "false" - no files, "modified" will only read the file if the contents have been changed, default:false
  flatten: false                    // if true, will flatten the response
  sort: "asc"                        // TODO - sort by depth if flat asc or desc
});

// when finished, array passed with all file and directory details
// will inc. contents if readFile:true or if readFile:"modified" and contents have changed
console.log(response);

example response for a file. contents will be undefined if readFile: false. modified will be true if the contents have changed, or if the file was created since the last walk (since the last time the function was called)

[
  {
    stats: Stats {
      dev: 16777220,
      mode: 33188,
      nlink: 1,
      uid: 501,
      gid: 20,
      rdev: 0,
      blksize: 4096,
      ino: 59344407,
      size: 4214700,
      blocks: 8320,
      atimeMs: 1613435111889.6147,
      mtimeMs: 1613432214420.2336,
      ctimeMs: 1613432214420.2336,
      birthtimeMs: 1613431128666.037,
      atime: 2021-02-16T00:25:11.890Z,
      mtime: 2021-02-15T23:36:54.420Z,
      ctime: 2021-02-15T23:36:54.420Z,
      birthtime: 2021-02-15T23:18:48.666Z
    },
    path: 'test/index.txt',
    name: 'index.txt',
    contents: <Buffer 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 20 61 64 69 70 69 73 69 63 69 6e ... 4214650 more bytes>,
    modified: true,
    depth: 0
  },
  [],  /* ignored directory */
  {},  /* ignored file */
  [    /* sub directory */
    {...},
    {...},
    [
      {...},
      {...},
      {...}
    ],
    {...}
  ]
]
3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago