Skip to content

Commit

Permalink
allow the external-scripts.json to be an object
Browse files Browse the repository at this point in the history
specify scripts in a module to load:

{
  "module-name": [
    "scripts",
    "to",
    "load"
  ],
  "modulename-2": [
    "more",
    "scripts",
    "toload"
  ]
}

or the old array containing multiple module names loading all scripts in the
module:

[ "module-name", "modulename-2" ]
  • Loading branch information
tombell committed Sep 5, 2013
1 parent eb1dd2c commit 5b21536
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/robot.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,16 @@ class Robot
# Returns nothing.
loadExternalScripts: (packages) ->
@logger.debug "Loading external-scripts from npm packages"
for pkg in packages
try
require(pkg) @
catch error
@logger.error "Error loading scripts from npm package - #{error}"
process.exit(1)
try
if packages instanceof Array
for pkg in packages
require(pkg)(@)
else
for pkg, scripts of packages
require(pkg)(@, scripts)
catch err
@logger.error "Error loading scripts from npm package - #{err.stack}"
process.exit(1)

# Setup the Express server's defaults.
#
Expand Down

0 comments on commit 5b21536

Please sign in to comment.