/*
 * min-webdriver
 *
 * Copyright (c) 2014 Maximilian Antoni <mail@maxantoni.de>
 *
 * @license MIT
 */
'use strict';

var path    = require('path');
var through = require('through');
var resolve = require('resolve');
var driver  = require('../lib/driver');
var options = require('../lib/options');


function addFile(b, file, expose) {
  b.add('./' + path.relative(process.cwd(), file).replace(/\\/g, '/'), {
    expose : expose
  });
}

module.exports = function (b, opts) {

  var broutFile = resolve.sync('brout', {
    baseDir: __dirname,
    packageFilter: function (pkg) {
      return { main : pkg.browser };
    }
  });
  addFile(b, broutFile, 'brout');
  var clientFile = path.join(__dirname, 'client.js');
  addFile(b, clientFile, 'min-wd');

  var stream = through();
  var wrap = b.pipeline.get('wrap');
  wrap.push(stream);
  wrap.push(through(function () {
    // Swallow.
    return;
  }));
  wrap.push(driver(stream, options(opts || {}), function (err) {
    if (err) {
      b.emit('error', err);
    }
  }));

};

@@ -309,43 +309,34 @@
 ion 
-addFile(b, file, expose) %7B%0A  b.add(
+relative(file) %7B%0A  return 
 './'
@@ -396,36 +396,8 @@
 '/')
-, %7B%0A    expose : expose%0A  %7D)
 ;%0A%7D%0A
@@ -440,193 +440,8 @@
  %7B%0A%0A
-  var broutFile = resolve.sync('brout', %7B%0A    baseDir: __dirname,%0A    packageFilter: function (pkg) %7B%0A      return %7B main : pkg.browser %7D;%0A    %7D%0A  %7D);%0A  addFile(b, broutFile, 'brout');%0A
   va
@@ -496,19 +496,23 @@
 ;%0A  
+b.
 add
-File(b, 
+(relative(
 clie
@@ -517,17 +517,33 @@
 ientFile
+)
 ,
+ %7B%0A    expose :
  'min-wd
@@ -543,16 +543,20 @@
 'min-wd'
+%0A  %7D
 );%0A%0A  va

Remove brout again