1.0.10 • Published 3 years ago

files-lookup v1.0.10

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

files-lookup

This serves as a module to traverse through files and directories and search for specific lines in specific files or delete in bulk. The files can be filtered with the help of regex. It uses the graceful-fs module so you dont get the EMFILE errors by searching for too many files which was the problem with fileSniffer

USAGE

This traverses the files and directories within the paths upto a certain depth and returns all the matches on all the lines of the files.

const file_ops = require('files-lookup')
const res = file_ops.searchFiles({
  paths: [
    'testPath/dir',
    'operations.js'
  ],
  onFiles: /[^]*/,  // optional
  matchLines: /[^]*/, // optional
  depth: 2 // optional;
})

console.log(res)

To delete files with secific pattern of files names until a specific depth

const file_ops = require('files-lookup')
file_ops.deleteFiles({
  paths: [
    'testPath/dir',
    'operations.js'
  ],
  onFiles: /[^]*/,  // optional
  depth: 2 // optional;
})

To delete the whole path

const file_ops = require('files-lookup')
file_ops.deletePath({
  paths: [
    'testPath/dir',
    'operations.js'
  ],
})

Changes

1.0.10

  • Changed how path was shown in the result