Fix small bugs
This commit is contained in:
@@ -40,6 +40,10 @@ export function rename(oldPath, newPath) {
|
||||
return fs.renameSync(oldPath, newPath);
|
||||
}
|
||||
|
||||
export function unlinkSync(fileToDelete) {
|
||||
return fs.unlinkSync(fileToDelete);
|
||||
}
|
||||
|
||||
export function createWriteStream(path, options) {
|
||||
return cloneObject(fs.createWriteStream(path, options));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,36 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import Module from "module";
|
||||
|
||||
// const Module = require("module");
|
||||
Module.globalPaths.push(path.resolve(process.env.DISCORD_APP_PATH, "..", "app.asar", "node_modules"));
|
||||
// module.paths.push(path.resolve(process.env.DISCORD_APP_PATH, "..", "app.asar", "node_modules"));
|
||||
|
||||
Module._load = (load => (req, parent, isMain) => {
|
||||
if (req.includes("./") || req.includes("..")) return load(req, parent, isMain);
|
||||
const found = Module.globalPaths.find(m => fs.existsSync(path.resolve(m, req)));
|
||||
|
||||
return found ? load(path.resolve(found, req), parent, isMain) : load(req, parent, isMain);
|
||||
})(Module._load);
|
||||
|
||||
// const originalLoad = Module.prototype.load;
|
||||
// Module.prototype.load = function() {
|
||||
// const returnValue = Reflect.apply(originalLoad, this, arguments);
|
||||
// console.log(this, arguments, returnValue);
|
||||
// return returnValue;
|
||||
// };
|
||||
|
||||
|
||||
// const nodeModulePaths = Module._nodeModulePaths;
|
||||
// console.log(nodeModulePaths);
|
||||
// Module._nodeModulePaths = (from) => {
|
||||
// return nodeModulePaths(from).concat([path.resolve(process.env.DISCORD_APP_PATH, "..", "app.asar", "node_modules")]);
|
||||
// };
|
||||
|
||||
// console.log(Module._nodeModulePaths, Module._nodeModulePaths("request"));
|
||||
// console.dir(Module);
|
||||
// console.log(Object.keys(Module));
|
||||
// console.log(require("request"));
|
||||
|
||||
export * as filesystem from "./filesystem";
|
||||
export * as https from "./https";
|
||||
@@ -11,4 +40,4 @@ export * as crypto from "./crypto";
|
||||
// We can expose that without any issues.
|
||||
export * as path from "path";
|
||||
export * as net from "net"; // TODO: evaluate need and create wrapper
|
||||
export * as os from "os";
|
||||
export * as os from "os";
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import cloneObject from "common/clone";
|
||||
import cloneObject, {getKeys} from "common/clone";
|
||||
|
||||
export default cloneObject(process, {});
|
||||
export default cloneObject(process, {}, getKeys(process).filter(p => p !== "config"));
|
||||
Reference in New Issue
Block a user