85d2225e0c
* Fix loading within the CLI * Remove app * Remove promise handle * Add initial travis file * Add libxkbfile dependency * Add libxkbfile-dev * Add build script * Fix malformed bash statement * Remove yarn from script * Improve build script * Extract upx before usage * Only run upx if on linux * Ensure resource directory exists * Pack runnable binary * Export binary with platform * Improve build process * Install upx before running install script * Update typescript version before running nexe * Add os.release() function for multi-platform support * Update travis.yml to improve deployment * Add on CI * Update to v1.31.0 * Add libsecret * Update build target * Skip cleanup * Fix built-in extensions * Add basics for apps * Create custom DNS server * Fix forking within CLI. Fixes TS language features * Fix filename resolve * Fix default extensions path * Add custom dialog * Store workspace path * Remove outfiles * Cleanup * Always authed outside of CLI * Use location.host for client * Remove useless app interface * Remove debug file for building wordlist * Use chromes tcp host * Update patch * Build browser app before packaging * Replace all css containing file:// URLs, fix webviews * Fix save * Fix mkdir
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import * as fs from "fs";
|
|
import * as path from "path";
|
|
import { isCli, buildDir } from "./constants";
|
|
|
|
declare var __non_webpack_require__: typeof require;
|
|
|
|
/**
|
|
* Handling of native modules within the CLI
|
|
*/
|
|
export const setup = (dataDirectory: string): void => {
|
|
if (!isCli) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
fs.mkdirSync(path.join(dataDirectory, "modules"));
|
|
} catch (ex) {
|
|
if (ex.code !== "EEXIST") {
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
const unpackModule = (moduleName: string): void => {
|
|
const memFile = path.join(buildDir!, "build/modules", moduleName + ".node");
|
|
const diskFile = path.join(dataDirectory, "modules", moduleName + ".node");
|
|
if (!fs.existsSync(diskFile)) {
|
|
fs.writeFileSync(diskFile, fs.readFileSync(memFile));
|
|
}
|
|
};
|
|
|
|
/**
|
|
* We need to unpack node-pty and patch its `loadNative` function to require our unpacked pty.node
|
|
* If pty.node isn't unpacked a SIGSEGV is thrown and the application exits. The exact reasoning
|
|
* for this is unknown ATM, but this patch works around it.
|
|
*/
|
|
unpackModule("pty");
|
|
const nodePtyUtils = require("../../protocol/node_modules/node-pty/lib/utils") as typeof import("../../protocol/node_modules/node-pty/src/utils");
|
|
// tslint:disable-next-line:no-any
|
|
nodePtyUtils.loadNative = (modName: string): any => {
|
|
return __non_webpack_require__(path.join(dataDirectory, "modules", modName + ".node"));
|
|
};
|
|
// tslint:disable-next-line:no-unused-expression
|
|
require("../../protocol/node_modules/node-pty/lib/index") as typeof import("../../protocol/node_modules/node-pty/src/index");
|
|
};
|