1.2.2 • Published 1 year ago

find-files-extra v1.2.2

Weekly downloads
-
License
The Unlicense
Repository
github
Last release
1 year ago

Simple (with advanced feature) file search

Examples

// Find all json files (Loading content + parse to json)
let jsonFiles = await findFileExtra({
  root: MY_PROJECT_ROOT,
  filePattern: "**/*.json",
  loadFileContent: true,
  parseJson: true,
});

// Find all ts files with 'search-me' in content (Not loading content)
let files = await findFileExtra({
  root: MY_PROJECT_ROOT,
  filePattern: "**/*.ts",
  fileContentPattern: "search-me",
});

// Find all ts files with content that match regexp (Loading content)
let files = await findFileExtra({
  root: MY_PROJECT_ROOT,
  filePattern: "**/*.ts",
  fileContentPattern: /search\-me|searchMe/,
  loadFileContent: true,
});

Result

The result is list of findFileExtraFileInfo (interface)

export interface findFileExtraFileInfo {
  fullPath: string;
  pathFromRoot: string;
  fileName: string;
  dirFullPath: string;
  dirPathFromRoot: string;
  ext: string;
  json?: unknown;
  content?: string;
}

Options

OptionRequiredTypeDefaultDescription
roottruestring-Root directory to search in.
filePatternfalsestring"**/*.*"File pattern to search for. glob pattern
ignoreFilePatternfalsestring[]["**/bin/**", "**/node_modules/**", "**/obj/**"]File pattern to ignore. glob pattern
fileContentPatternfalseregexp / stringundefinedFile content pattern to search for.
loadFileContentfalsebooleanfalseLoad file content.
parseJsonfalsebooleanfalseParse file content to json.
dotfalsebooleantrueUse dot notation for json keys.
nocasefalsebooleantrueCase insensitive search.

parseJson requires loadFileContent to be true.

if filePattern and fileContentPattern is both undefined (not set) all files will be found in the root.

Installation

  • npm install find-files-extra
  • yarn add find-files-extra
1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago