How to use the vscode-ripgrep.rgPath.replace function in vscode-ripgrep

To help you get started, we’ve selected a few vscode-ripgrep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esrlabs / chipmunk / application / electron / src / rg.ts View on Github external
import { rgPath } from 'vscode-ripgrep';
import { spawn, ChildProcess } from 'child_process';
import * as path from 'path';
import * as fs from 'fs';
import * as Stream from 'stream';
import * as tty from 'tty';

const cmd: string = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.unpacked');

const readStream = fs.createReadStream('/Users/dmitry.astafyev/WebstormProjects/logviewer/logs_examples/tm_b.log', { start: 90, end: 999, autoClose: true, encoding: 'utf8' });
readStream.on('open', (fd) => {

    const rg = spawn(cmd, ['-N', '-e', '12:38', '-'], {
        stdio: ['pipe', 'inherit', 'ignore'],
    });
    //process.stdin.write('fdsfds0.9149597fsd\n\r');
    //process.stdin.end('\n\r');
    readStream.pipe(rg.stdin);


    readStream.on('data', (chunk) => {
        // rg.stdin.write('\n\r');
        console.log(`READ: ${chunk}`);
    });
github atom / fuzzy-finder / lib / load-paths-handler.js View on Github external
/* global emit */

const async = require('async')
const fs = require('fs')
const os = require('os')
const path = require('path')
const {GitRepository} = require('atom')
const {Minimatch} = require('minimatch')
const childProcess = require('child_process')
const { rgPath } = require('vscode-ripgrep')

const PathsChunkSize = 100

// Use the unpacked path if the ripgrep binary is in asar archive.
const realRgPath = rgPath.replace(/\bapp\.asar\b/, 'app.asar.unpacked')

// Define the maximum number of concurrent crawling processes based on the number of CPUs
// with a maximum value of 8 and minimum of 1.
const MaxConcurrentCrawls = Math.min(Math.max(os.cpus().length - 1, 8), 1)

const emittedPaths = new Set()

class PathLoader {
  constructor (rootPath, ignoreVcsIgnores, traverseSymlinkDirectories, ignoredNames, useRipGrep) {
    this.rootPath = rootPath
    this.ignoreVcsIgnores = ignoreVcsIgnores
    this.traverseSymlinkDirectories = traverseSymlinkDirectories
    this.ignoredNames = ignoredNames
    this.useRipGrep = useRipGrep
    this.paths = []
    this.inodes = new Set()
github marktext / marktext / src / renderer / node / paths.js View on Github external
import { rgPath } from 'vscode-ripgrep'
import EnvPaths from 'common/envPaths'

// "vscode-ripgrep" is unpacked out of asar because of the binary.
const rgDiskPath = rgPath.replace(/\bapp\.asar\b/, 'app.asar.unpacked')

class RendererPaths extends EnvPaths {
  /**
   * Configure and sets all application paths.
   *
   * @param {string} userDataPath The user data path.
   */
  constructor (userDataPath) {
    if (!userDataPath) {
      throw new Error('No user data path is given.')
    }

    // Initialize environment paths
    super(userDataPath)

    // Allow to use a local ripgrep binary (e.g. an optimized version).
github esrlabs / chipmunk / application / electron / src / controllers / controller.stream.search.rg.ts View on Github external
export interface IMatch {
    text: string;
    index: number;
}

export interface IRegDescription {
    reg: RegExp;
    groups: number;
}

export class RGSearchWrapper {

    private _logger: Logger;
    private _targetFile: string;
    private _resultsFile: string;
    private _cmd: string = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.unpacked');
    private _process: ChildProcess | undefined;
    private _last: string | undefined;

    constructor(targetFile: string, resultsFile: string) {
        this._targetFile = targetFile;
        this._resultsFile = resultsFile;
        this._logger = new Logger(`RGSearchWrapper (${path.basename(targetFile)})`);
    }

    public search(regExp: RegExp | RegExp[]): Promise {
        return new Promise((resolve, reject) => {
            if (this._process !== undefined) {
                return new Error(this._logger.warn(`Cannot start new search because previous isn't finished yet.`));
            }
            if (!(regExp instanceof Array)) {
                regExp = [regExp];

vscode-ripgrep

A module for using ripgrep in a Node project

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Similar packages