Skip to content

πŸ”πŸ’» Find code snippets in your project

License

Notifications You must be signed in to change notification settings

JasonEtco/find-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”πŸ’»πŸ”Ž

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:

Property Default Description
directory process.cwd() Directory to scan
exclude ['node_modules'] Directories to exclude from the scan

About

πŸ”πŸ’» Find code snippets in your project

Resources

License

Stars

Watchers

Forks

Packages

No packages published