-
Notifications
You must be signed in to change notification settings - Fork 91
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
Update generated index.coffee to use fs.existsSync #19
Conversation
Script loading should be synchronous, to preserve script load order and allow the script to behave as expected with the `--config-check` hubot flag. Also ensure the scripts are loaded in alphabetical order. This matches how hubot loads scripts from the scripts/ directory.
Thinking about this a little bit, and one nice thing about the change you proposed to the docs in hubotio/hubot#831 with just calling I think the only 'weird' thing about making the index.coffee try to load everything in I'm thinking to perhaps replace this with like: path = require 'path'
module.exports = (robot, scripts) ->
scriptsPath = path.resolve(__dirname, 'src')
robot.loadFile(scriptsPath, "hardcoded.coffee") Because this is a generator, and we are creating the file in |
@technicalpickles Generating code like that makes it hard to then add extra src files in the future, if you expect them to load automatically by being present (which is how the existing code works). I guess it depends on what you expect to happen when adding a new file to the |
Things are weird one way or the other. Either it assumes that everything in Another thing that had bugged me was that it is a bit boiler plately, and I was having trouble parsing why it's going through reading the directory, and conditionally loading files. Then I remembered why: https://github.com/github/hubot/blob/master/src/robot.coffee#L252-L266 . Basically, it lets you have external-scripts.json as a object, where you can list out which files to load or '*' for all of them. |
So, I think it's probably best to go with this way for now just to get the sync directory reading, and can reconsider changing the default later on in #20 |
Yeah, I think the conditional load stuff makes more sense if your package contains a |
Update generated index.coffee to use fs.existsSync
Script loading should be synchronous, to preserve script load order and
allow the script to behave as expected with the
--config-check
hubotflag. Also ensure the scripts are loaded in alphabetical order. This
matches how hubot loads scripts from the scripts/ directory.