Skip to content

Instantly share code, notes, and snippets.

@nakosung
Created March 12, 2014 09:46
Show Gist options
  • Save nakosung/9503843 to your computer and use it in GitHub Desktop.
Save nakosung/9503843 to your computer and use it in GitHub Desktop.
inject = (target,injected_modules) ->
fs = require 'fs'
coffeescript = require 'coffee-script'
index = (fs.readFileSync target).toString()
index = (index.split('\n').map (x) -> "\t#{x}").join('\n')
source = "(require) ->\n#{index}"
(coffeescript.eval source) (module) ->
injected_modules[module] or require module
cargoship = require 'cargoship'
inject 'index.coffee',
cargoship : ->
ship = cargoship()
org = ship.launch.bind(ship)
ship.launch = (name,args...) ->
console.log 'launching test!'
org 'TEST_' + name, args...
ship
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment