Skip to content

Feature: Custom Actions #38

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
},
"dependencies": {
"coffee-script": "~1.6",
"url": "~0.7.9",
"querystring": "~0.2.0"
"lodash": "^4.17.2",
"querystring": "~0.2.0",
"url": "~0.7.9"
},
"devDependencies": {
"mocha": "*",
Expand Down
6 changes: 5 additions & 1 deletion src/github-repo-event-notifier.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@
# patcon
# parkr

_ = require('lodash')
inspect = (require('util')).inspect
url = require('url')
querystring = require('querystring')
eventActions = require('./event-actions/all')
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."

eventActions = _.assign(require('./event-actions/all'), customActions)

if eventTypesRaw?
###
Expand Down