Skip to content
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

Feature: Custom Actions #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benoror
Copy link

@benoror benoror commented Dec 3, 2016

Fix
#37

@benoror
Copy link
Author

benoror commented Dec 3, 2016

How it works: Simply place your "custom actions" module inside scripts/github/custom-actions.js on your hubot's project root and override desired actions like this:

module.exports = {
  release: function(adapter, data, cb) {
    var res = data.action + ': ' + data.release + '\n';
    res += data.release.html_url + '\n'
    res += data.release.body;
    cb(res);
  }
};

(Tested Locally & Heroku)

@benoror
Copy link
Author

benoror commented Dec 16, 2016

@patcon @parkr Any feedback on this? Let me know if you need any kind of help!

@benoror benoror mentioned this pull request Dec 16, 2016
@benoror
Copy link
Author

benoror commented Jan 8, 2017

@patcon @parkr ping ❤️

eventTypesRaw = process.env['HUBOT_GITHUB_EVENT_NOTIFIER_TYPES']
eventTypes = []
customActions = {}
try
customActions = require.main.require('../../../scripts/github/custom-actions')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about this very narrow path choice – would it be possible to use a user-specified path instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parkr this a relative path to the user's hubot repo, therefore if the repo is called my-hubot then this particular file (github-repo-event-notifier.coffee) would be located under:

my-hubot\node_modules\hubot-github-repo-event-notifier\src

Hence the path.

Nevertheless it would be possible to refactor it using built-in "path" api, and let the user specify the last dir/file part (scripts/github/custom-actions in this case)

My only question is, where should the user put that configuration?

Cheers!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we always assume that this project will be installed into my-hubot\node_modules\hubot-github-repo-event-notifier\src? It seems like a very fragile assumption to me as node modules are nested if they are a dependency of a dependency.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parkr would you be open to use something like findup-sync?

That's the closest thing I found regarding accessing node_module's parent directories.

Let me know if you are aware of another method/lib, otherwise I can update the PR. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benoror That would make sense. Would it perhaps be better to go around all the automated inclusion (i.e. including this project name in external-scripts.json)? The user would add it to their package.json, then write a custom file in scripts/ which includes this project and hooks it up properly for Hubot to include. That way you could add your own handlers without it being really convoluted and "magical."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants