-
Notifications
You must be signed in to change notification settings - Fork 23
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
Cannot require a customized js file #285
Comments
You need to call your method See https://github.com/httpyac/httpyac.github.io/blob/main/examples/script/scriptRequire.http |
I called the method with following codes: ### Test Common Functions
{{
const test = require('./test.js')
test.TestFunc()
}} Unfortunately I got nothing output... |
It works, but not the way you expect it to. It works directly on the command line. In vscode it would also work, but the console output is not the output channel but really stdout. For scripts that I execute directly, I overwrite the console output so that it appears in the OutputChannel. For require scripts I have not yet found a trick for this, so it writes directly to stdout. Pass the function the reference to the console then it would work.
const TestFunc = (c) => {
c.log("test");
};
exports.TestFunc = TestFunc |
Yeah ,passing the outer console object to the required function works, it print to OutputChannel and the log can be read in the httpyac Console. And if there is a way to overwrite the global |
PR is welcome. I've been looking into NodeJS vm for a while, but haven't found it. If you have an idea, please feel free. |
@AnWeber Quote of the day: "It works, but not the way you expect it to." :-) |
A js file which exports some functions is required by a http script, however the requiring result is only an empty object.
JS file: test.js
test.http file
Guess what is printed...
It turns out to be just an empty object.
So how can I write a js file which can be required by the http file?
The text was updated successfully, but these errors were encountered: