Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

find-code

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-code

Find code snippets in your project

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

🔍💻🔎

find-code

Find code snippets in your project

NPM Build Status Codecov

Usage

Installation

$ npm install find-code
const findCode = require('find-code')

How it works

const foundCode = await findCode(/featuredEnabled\('.*'\)/, { directory: './lib' })
console.log(foundCode)
// [{
//  file: 'my-module.js',
//  path: '/Users/Jason/dev/secret-project/lib/my-module.js',
//  line: 'if (user.featureEnabled('my-feature')) {',
//  lineNumber: 2
//  block: '// This checks if the feature is enabled\nif (user.featureEnabled('my-feature')) {\nconsole.log('Yay!')
// }]

API

findCode(query, options)

query:

The first argument can be a string or a regular expression:

const foundCode = await findCode(/featuredEnabled\('.*'\)/)
const foundCode = await findCode('const')

options:

PropertyDefaultDescription
directoryprocess.cwd()Directory to scan
exclude['node_modules']Directories to exclude from the scan

FAQs

Package last updated on 30 Aug 2018

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