node-theseus
node-theseus copied to clipboard
Detecting of activation mode fails under node-theseus
We use this to detect activation mode: if (require.main === module) { //started directly } else { //started by 'require' }
it works fine under 'node' but fails under node-theseus
Hmm, yes, that would happen since node-theseus launches your script with require(scriptPath)
.
Two ideas come to mind:
- Change it to
require.main = require(scriptPath)
. (I'm pretty sure this won't work, but it's easy. :) - Maybe
require()
has an argument for settingrequire.main
? -
Modify
beginInstrumentation
to detect the main script and prependrequire.main = module
.
Thanks for the report! I hadn't even known about require.main
. :) Sorry that node-theseus didn't just work.
Hi Tom, Thank you very much. I will try. Well done for the excellent tool, and for the prompt response! Best regards, -Itay
2014-09-29 18:34 GMT+03:00 Tom Lieber [email protected]:
Hmm, yes, that would happen since node-theseus launches your script with require(scriptPath) https://github.com/adobe-research/node-theseus/blob/master/node-theseus.js#L91 .
Two ideas come to mind:
- Change it to require.main = require(scriptPath). (I'm pretty sure this won't work, but it's easy. :)
- Maybe require() has an argument for setting require.main?
- Modify beginInstrumentation https://github.com/adobe-research/node-theseus/blob/master/node-theseus.js#L137-L165 to detect the main script and prepend require.main = module.
Thanks for the report! I hadn't even known about require.main. :) Sorry that this didn't just work.
— Reply to this email directly or view it on GitHub https://github.com/adobe-research/node-theseus/issues/24#issuecomment-57179428 .