Skip to content

Commit

Permalink
Fix file permissions, fix rg launch path when using asar
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jan 26, 2018
1 parent 2970cf5 commit 6225dcc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 4 additions & 1 deletion build/lib/asar.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function createAsar(folderPath, unpackGlobs, destFilename) {
cwd: folderPath,
base: folderPath,
path: path.join(destFilename + '.unpacked', relative),
stat: file.stat,
contents: file.contents
}));
}
Expand All @@ -84,11 +85,13 @@ function createAsar(folderPath, unpackGlobs, destFilename) {
out.unshift(headerBuf);
out.unshift(sizeBuf);
}
var contents = Buffer.concat(out);
out.length = 0;
_this.queue(new VinylFile({
cwd: folderPath,
base: folderPath,
path: destFilename,
contents: Buffer.concat(out)
contents: contents
}));
_this.queue(null);
};
Expand Down
6 changes: 5 additions & 1 deletion build/lib/asar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function createAsar(folderPath: string, unpackGlobs: string[], destFilena
cwd: folderPath,
base: folderPath,
path: path.join(destFilename + '.unpacked', relative),
stat: file.stat,
contents: file.contents
}));
} else {
Expand All @@ -97,11 +98,14 @@ export function createAsar(folderPath: string, unpackGlobs: string[], destFilena
out.unshift(sizeBuf);
}

const contents = Buffer.concat(out);
out.length = 0;

this.queue(new VinylFile({
cwd: folderPath,
base: folderPath,
path: destFilename,
contents: Buffer.concat(out)
contents: contents
}));
this.queue(null);
};
Expand Down
5 changes: 4 additions & 1 deletion src/vs/workbench/services/search/node/ripgrepFileSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ import { normalizeNFD, startsWith } from 'vs/base/common/strings';
import { IFolderSearch, IRawSearch } from './search';
import { foldersToIncludeGlobs, foldersToRgExcludeGlobs } from './ripgrepTextSearch';

// If vscode-ripgrep is in an .asar file, then the binary is unpacked.
const rgDiskPath = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.unpacked');

export function spawnRipgrepCmd(config: IRawSearch, folderQuery: IFolderSearch, includePattern: glob.IExpression, excludePattern: glob.IExpression) {
const rgArgs = getRgArgs(config, folderQuery, includePattern, excludePattern);
const cwd = folderQuery.folder;
return {
cmd: cp.spawn(rgPath, rgArgs.args, { cwd }),
cmd: cp.spawn(rgDiskPath, rgArgs.args, { cwd }),
siblingClauses: rgArgs.siblingClauses,
rgArgs,
cwd
Expand Down
5 changes: 4 additions & 1 deletion src/vs/workbench/services/search/node/ripgrepTextSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { ISerializedFileMatch, ISerializedSearchComplete, IRawSearch, IFolderSearch, LineMatch, FileMatch } from './search';
import { IProgress } from 'vs/platform/search/common/search';

// If vscode-ripgrep is in an .asar file, then the binary is unpacked.
const rgDiskPath = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.unpacked');

export class RipgrepEngine {
private isDone = false;
private rgProc: cp.ChildProcess;
Expand Down Expand Up @@ -72,7 +75,7 @@ export class RipgrepEngine {

onMessage({ message: rgCmd });
});
this.rgProc = cp.spawn(rgPath, rgArgs.args, { cwd });
this.rgProc = cp.spawn(rgDiskPath, rgArgs.args, { cwd });
process.once('exit', this.killRgProcFn);

this.ripgrepParser = new RipgrepParser(this.config.maxResults, cwd, this.config.extraFiles);
Expand Down

0 comments on commit 6225dcc

Please sign in to comment.