-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
robot.load tries to load both .coffee and .js versions of script when transpiled #653
Comments
That makes sense I think. I'm curious, how are you getting compiled javascript files in scripts directory? hubot is normally run in-line, so it wouldn't compile by default, instead just compiling in memory and executing them that way. |
Here are the steps to get the compiled js.
|
I wrote this in email, but posting here for completeness:
|
Updated title to reflect the issue. |
It's wierd that the script get's loaded twice since loadFile loads the .js only if there is not .coffee with the same filename:
I also have issues debugging my bot because of this. I was about to send a pull request so loadHubotScripts ignore .coffee if there is a .js file with the same name. This would assume that the .js is transpiled and up to date with the .coffee counterpart. To answer technicalpickles on why this is useful, here how it works in IntelliJ. IntelliJ does not support debugging of coffeescript but can debug node/javascript. However, it does support map files generated by the coffeescript transpiler to allow breakpoints and some debugging (see current execution line, step, basic variable inspection, ...) from the .coffee file. But all this is just mapping magic, not real coffeescript debugging. In the case of the robot Does it makes sense? |
Any comment on this? I am willing to send a pull request but I don't want to send something that's too far off. |
I think this makes sense, so 👍 to a PR cc #667 since it's sorta in the same spot in the code base |
c.f. #648 since this is probably useful information to include in the debugging docs |
Hi all,
There is an issue with the Load function
Fs.exists path, (exists) =>
if exists
for file in Fs.readdirSync(path).sort()
@loadfile path, file
The issue is present when you have both a js file and a coffee script file in the scripts folder (this happens when you transpile the coffee script (produces a js file in the same directory)). Since the for loop is not checking if a script by that name is already added it will add both the coffee script and the javascript, resulting in a duplicate.
So when you call
hubot ping
you get
pong
pong
I am very new to coffee script, so not going to try to submit a patch, but here is my 2 cents on fixing it.
When you are iterating through the files and the ext is '.js' replace the ext with '.coffee' and check if a file by that name is already loaded. If so do not load it.
Cheers
Paul
The text was updated successfully, but these errors were encountered: