You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
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
Version published
Weekly downloads
8
-20%
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