-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intercept absolute paths #43
Comments
This module is meant as a way to patch files in 3rd party modules that you can't normally edit yourself. If the file you're trying to patch is not inside |
I am trying to patch the runtime internals of AWS lambda. Specifically, the |
I am happy to provide a PR if you'd like. I already modified a version locally which works with the restriction that the only way to intercept files like this is by specifying their absolute path in the whitelist. const Hook = require("require-in-the-middle");
// also works with "/var/runtime/RAPIDClient.js"
Hook(["/var/runtime/RAPIDClient"], (exports, name, basedir) => {
console.log(name) // RAPIDClient
console.log(basedir) // /var/runtime
return exports;
}); |
Yes, please send a PR. It would be great to support this use-case |
It seems like it is impossible to use require-in-the-middle to intercept requires of absolute file paths. For instance, I would like to intercept the require of
/var/runtime/util.js
which is outside of mynode_modules
and not a core module. I tried to dohook(['/var/runtime/util'], onRequire)
, but whenrequire('/var/runtime/util')
is called, require-in-the-middle logsrequire-in-the-middle could not parse filename: /var/runtime/util.js +0ms
.It looks like require-in-the-middle is using the module-details-from-path module, which fails to parse this absolute path.
The text was updated successfully, but these errors were encountered: