Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/purocean/ripgrep-wrapper
A wrapper around Ripgrep that allows for use in node.
https://github.com/purocean/ripgrep-wrapper
Last synced: 27 days ago
JSON representation
A wrapper around Ripgrep that allows for use in node.
- Host: GitHub
- URL: https://github.com/purocean/ripgrep-wrapper
- Owner: purocean
- License: mit
- Created: 2022-11-15T06:16:32.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-20T07:54:49.000Z (almost 2 years ago)
- Last Synced: 2024-10-08T04:32:25.636Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 110 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ripgrep-wrapper
A wrapper for ripgrep that allows you to search for files in a directory and subdirectories.
The codes of this project are cherry picked from [vscode](https://github.com/microsoft/vscode). Thanks to the vscode and ripgrep.
## Usage
1. Install `ripgrep-wrapper` and `@vscode/ripgrep`
```bash
npm install ripgrep-wrapper @vscode/ripgrep
```2. Use `ripgrep-wrapper` to search files
```typescript
import { rgPath } from '@vscode/ripgrep';
import { CancellationTokenSource, ITextQuery, TextSearchEngineAdapter } from 'ripgrep-wrapper';const cts = new CancellationTokenSource()
// search query. refer to types/search#ITextQuery for more details
const query: ITextQuery = {
contentPattern: {
pattern: 'test'
},
folderQueries: [
{ folder: __dirname as any }
]
}const searchEngine = new TextSearchEngineAdapter(rgPath, query)
const successResult = await searchEngine.search(cts.token, (res) => {
console.log('onResult', res)
}, message => {
console.log('onMessage', message)
})console.log('successResult', successResult)
```