Skip to content

Commit

Permalink
Move scripts into src/scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Bell committed Nov 4, 2011
1 parent b53c745 commit 9d1a31f
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 19 deletions.
37 changes: 23 additions & 14 deletions bin/hubot
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,26 @@ Creator = require '../src/creator'
OptParse = require 'optparse'
PortNumber = parseInt(process.env.PORT) || 8080

Adapters = ["irc", "campfire", "hipchat", "twilio", "xmpp", "groupme", "talker", "twitter", "flowdock", "gtalk"]
Adapters = [
"irc",
"campfire",
"hipchat",
"twilio",
"xmpp",
"groupme",
"talker",
"twitter",
"flowdock",
"gtalk"
]

Switches = [
[ "-h", "--help", "Display the help information"],
[ "-a", "--adapter ADAPTER", "The Adapter to use"],
[ "-c", "--create PATH", "Create a deployable hubot"],
[ "-s", "--enable-slash", "Enable replacing the robot's name with '/'"],
[ "-n", "--name NAME", "The name of the robot in chat" ],
[ "-v", "--version", "Displays the version of hubot installed"]
[ "-h", "--help", "Display the help information"],
[ "-a", "--adapter ADAPTER", "The Adapter to use"],
[ "-c", "--create PATH", "Create a deployable hubot"],
[ "-s", "--enable-slash", "Enable replacing the robot's name with '/'"],
[ "-n", "--name NAME", "The name of the robot in chat" ],
[ "-v", "--version", "Displays the version of hubot installed"]
]

Options =
Expand Down Expand Up @@ -80,12 +91,14 @@ else
else
'shell'

robot = Hubot.loadBot adapter, Options.name
robot.enableSlash = Options.enableSlash

scriptsPath = Path.resolve "./scripts"
console.log "Loading deploy-local scripts at #{scriptsPath}"
robot = Hubot.loadBot adapter, scriptsPath, Options.name
robot.enableSlash = Options.enableSlash
robot.load scriptsPath

scriptsPath = Path.resolve "src", "hubot", "scripts"
scriptsPath = Path.resolve "src", "scripts"
console.log "Loading hubot core scripts for relative scripts at #{scriptsPath}"
robot.load scriptsPath

Expand All @@ -96,10 +109,6 @@ else
Fs.readFile scriptsFile, (err, data) =>
JSON.parse(data).forEach (plugin) =>
robot.loadFile Path.resolve("node_modules", "hubot-scripts", "src", "scripts"), plugin
else
scriptsPath = Path.resolve "src", "scripts"
console.log "Loading hubot-scripts plugins at #{scriptsPath}"
robot.load scriptsPath

robot.run()

Expand Down
4 changes: 2 additions & 2 deletions index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# YourBot = Hubot.robot 'campfire', 'blah', 'yourbot'

# Loads a Hubot robot
exports.loadBot = (adapterName, path, botName) ->
exports.loadBot = (adapterName, botName) ->
robot = require "./src/adapters/#{adapterName}"
new robot path, botName
new robot botName

exports.robot = ->
require './src/robot'
Expand Down
4 changes: 1 addition & 3 deletions src/robot.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Robot
# dispatch them to matching listeners.
#
# path - String directory full of Hubot scripts to load.
constructor: (path, name = "Hubot") ->
constructor: (name = "Hubot") ->
@name = name
@brain = new Robot.Brain
@commands = []
Expand All @@ -17,8 +17,6 @@ class Robot
@loadPaths = []
@enableSlash = false

@load path if path

# Public: Adds a Listener that attempts to match incoming messages based on
# a Regex.
#
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 9d1a31f

Please sign in to comment.