New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

find-files-extra

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-files-extra

Simple file finder with both file name and content search options

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 31 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc