 mergeSandboxedHooks = require './merge-sandboxed-hooks'
 HooksWorkerClient = require './hooks-worker-client'
 
+# Ensure platform agnostic path.basename function
+basename = if process.platform is 'win32' then path.win32.basename else path.basename
 
 addHooks = (runner, transactions, callback) ->
   # Note: runner.configuration.options must be defined


          delete allHooks[hookType][transactionName]

  loadHookFile = (filename, basePath) ->
    basePath ?= customConfigCwd or process.cwd()
    filePath = path.resolve(basePath, filename)

    try
      proxyquire filePath, {
        'hooks': runner.hooks

    if typeof(runner.configuration.hooksData) != 'object' or Array.isArray(runner.configuration.hooksData) != false
      return callback(new Error("hooksData option must be an object e.g. {'filename.js':'console.log(\"Hey!\")'}"))

    # Run code in sandbox
    async.eachSeries Object.keys(runner.configuration.hooksData), (key, nextHook) ->
      data = runner.configuration.hooksData[key]

      # Run code in sandbox
      sandboxHooksCode data, (sandboxError, result) ->
        return nextHook(sandboxError) if sandboxError

        # Merge stringified hooks
        runner.hooks = mergeSandboxedHooks(runner.hooks, result)

        # Fixing #168 issue
