Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pavel-durov/file-scan
utility to scan files for text patterns
https://github.com/pavel-durov/file-scan
Last synced: 3 months ago
JSON representation
utility to scan files for text patterns
- Host: GitHub
- URL: https://github.com/pavel-durov/file-scan
- Owner: Pavel-Durov
- Created: 2020-08-02T10:02:49.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2024-09-19T17:18:32.000Z (4 months ago)
- Last Synced: 2024-10-02T10:07:57.559Z (3 months ago)
- Language: TypeScript
- Size: 511 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![CircleCI](https://circleci.com/gh/Pavel-Durov/file-scan/tree/develop.svg?style=svg)](https://circleci.com/gh/Pavel-Durov/file-scan/tree/develop)
## file-scan - utility to scan text files
## Table of Contents
1. [Install](#install)
2. [Examples](#examples)
3. [Test](#tests)
4. [Logs](#logs)## Install
```bash
# npm
npm install --save-dev @ihcmikmai/file-scan
# yarn
yarn add @ihcmikmai/file-scan --dev
```## Examples
```
$ file-scan -h
Usage: index [options]Options:
-V, --version output the version number
-p, --pattern regex pattern
-h, --help display help for command```
Scan all files in 2 level directories, ignoring node_modules directory
```bash
$ file-scan ./*[!node_modules]**/** --pattern secret
```+ if your regex include `\` escape them with `\\` :
```bash
--pattern "secret-\d+"
# should be
--pattern "secret-\\d+"
``````javascript
import { match, scanFiles } from '@ihcmikmai/file-scan';
// scanning via glob pattern
const results = await scan(/my-regex/, "./**/*.json");
// scanning via file list
const results = await scanFiles(/my-regex/, ["./file1.json", "./file2.json"])
```## Use file-scan as pre-commit hook
configure precommit, this example use [husky](https://github.com/typicode/husky):```json
"husky": {
"hooks": {
"pre-commit": "file-scan -p apikey-1234567890 ./**/**"
}
}
```## Tests
Run tests
```bash
yarn test
```Run tests with verbose logs
```bash
yarn test:verbose
```## Logs
```bash
FILE_SCAN_DEBUG=* file-scan
```