Make ripgrep executable on extract

This commit is contained in:
Kyle Carberry 2019-03-05 00:42:02 +00:00
parent 1e0d330778
commit 31518e9754
No known key found for this signature in database
GPG Key ID: 42E8F51E81E8201C
1 changed files with 6 additions and 2 deletions

View File

@ -22,11 +22,15 @@ export const setup = (dataDirectory: string): void => {
return currentDir; return currentDir;
}, os.platform() === "win32" ? undefined! : path.sep); // Might need path.sep here for linux. Having it for windows causes an error because \C:\Users ... }, os.platform() === "win32" ? undefined! : path.sep); // Might need path.sep here for linux. Having it for windows causes an error because \C:\Users ...
const unpackModule = (moduleName: string): void => { const unpackModule = (moduleName: string, markExecutable: boolean = false): void => {
const memFile = path.join(isCli ? buildDir! : path.join(__dirname, ".."), "build/dependencies", moduleName); const memFile = path.join(isCli ? buildDir! : path.join(__dirname, ".."), "build/dependencies", moduleName);
const diskFile = path.join(dataDirectory, "dependencies", moduleName); const diskFile = path.join(dataDirectory, "dependencies", moduleName);
if (!fs.existsSync(diskFile)) { if (!fs.existsSync(diskFile)) {
fs.writeFileSync(diskFile, fs.readFileSync(memFile)); fs.writeFileSync(diskFile, fs.readFileSync(memFile));
if (markExecutable) {
fs.chmodSync(diskFile, "755");
}
} }
}; };
@ -37,7 +41,7 @@ export const setup = (dataDirectory: string): void => {
*/ */
unpackModule("pty.node"); unpackModule("pty.node");
unpackModule("spdlog.node"); unpackModule("spdlog.node");
unpackModule("rg"); unpackModule("rg", true);
// const nodePtyUtils = require("../../protocol/node_modules/node-pty-prebuilt/lib/utils") as typeof import("../../protocol/node_modules/node-pty-prebuilt/src/utils"); // const nodePtyUtils = require("../../protocol/node_modules/node-pty-prebuilt/lib/utils") as typeof import("../../protocol/node_modules/node-pty-prebuilt/src/utils");
// tslint:disable-next-line:no-any // tslint:disable-next-line:no-any
// nodePtyUtils.loadNative = (modName: string): any => { // nodePtyUtils.loadNative = (modName: string): any => {