/**
 * Configurations.
 */
var path = require("path");

// Travis
var BUILD = process.env.TRAVIS_BUILD_NUMBER ?
  process.env.TRAVIS_BUILD_NUMBER + "@" + process.env.TRAVIS_COMMIT :
  "local";

// Sauce
var SAUCE_BRANCH = process.env.TRAVIS_BRANCH || "local";
var SAUCE_TAG = process.env.SAUCE_USERNAME + "@" + SAUCE_BRANCH;

// Browser Stack
var BROWSER_STACK_BRANCH = process.env.TRAVIS_BRANCH || "local";
var BROWSER_STACK_TAG = process.env.BROWSER_STACK_USERNAME + "@" +
  BROWSER_STACK_BRANCH;

module.exports = {
  /**
   * Misc. options.
   *
   * Options can be globally overriden with a merge of a stringified JSON
   * object like:
   * ```
   * ROWDY_OPTIONS='{ clientLogger: true }'
   * ```
   */
  options: {
    clientLogger: false,
    serverLogger: false,
    serverDebug: false
  },

  /**
   * Webdriver settings and capabilities.
   *
   * Select a path within this object using `ROWDY_SETTINGS="path.to.foo"`
   * Which will then infer all of the `default` settings at that level
   * and merge with specific fields.
   */
  settings: {
    /**
     * Local Selenium: `desiredCapabilities.browserName`
     *
     * Options:
     * - "firefox",
     * - "phantomjs"
     * - "chrome"
     * - "safari"
     * - "internet explorer"
     *
     * See: https://code.google.com/p/selenium/wiki/DesiredCapabilities
     */
    local: {
      default: {
        desiredCapabilities: {
          browserName: "phantomjs"
        },
        server: {
          start: true
        }
      },
      phantomjs: {
        desiredCapabilities: {
          browserName: "phantomjs"
        },
        server: {
          // Add path to NPM-installed Phantom EXE on Windows.
          phantomPath: process.platform === "win32" && path.join(__dirname,
            "../../node_modules/phantomjs/lib/phantom/phantomjs.exe")
        }
      },
      firefox: {
        desiredCapabilities: {
          browserName: "firefox"
        }
      },
      chrome: {
        desiredCapabilities: {
          browserName: "chrome"
        }
      },
      safari: {
        desiredCapabilities: {
          browserName: "safari"
        }
      },
      ie: {
        desiredCapabilities: {
          browserName: "internet explorer"
        }
      }
    },

    /**
     * SauceLabs.
     *
     * https://saucelabs.com/platforms
     */
    sauceLabs: {
      default: {
        desiredCapabilities: {
          name: "Rowdy Tests",
          tags: [SAUCE_TAG],
          public: "public",
          build: BUILD
        },
        remote: {
          hostname: "ondemand.saucelabs.com",
          port: 80,
          user: process.env.SAUCE_USERNAME,
          pwd: process.env.SAUCE_ACCESS_KEY
        },
        // Custom indicator of vendor service.
        isSauceLabs: true
      },
      "safari7-mac": {
        desiredCapabilities: {
          browserName: "safari",
          platform: "OS X 10.9",
          version: "7"
        }
      },
      "chrome-win7": {
        desiredCapabilities: {
          browserName: "chrome",
          platform: "Windows 7"
        }
      },
      "firefox-win7": {
        desiredCapabilities: {
          browserName: "firefox",
          platform: "Windows 7"
        }
      },
      "ie8-winxp": {
        desiredCapabilities: {
          browserName: "internet explorer",
          platform: "Windows XP",
          version: "8"
        }
      },
      "ie9-win7": {
        desiredCapabilities: {
          browserName: "internet explorer",
          platform: "Windows 7",
          version: "9"
        }
      },
      "ie10-win7": {
        desiredCapabilities: {
          browserName: "internet explorer",
          platform: "Windows 7",
          version: "10"
        }
      },
      "ie11-win8": {
        desiredCapabilities: {
          browserName: "internet explorer",
          platform: "Windows 8.1",
          version: "11"
        }
      }
    },

    /**
     * BrowserStack.
     *
     * http://www.browserstack.com/automate/capabilities
     */
    browserStack: {
      default: {
        desiredCapabilities: {
          name: BROWSER_STACK_TAG,
          project: "Rowdy Tests",
          build: BUILD
        },
        remote: {
          hostname: "hub.browserstack.com",
          port: 80,
          user: process.env.BROWSER_STACK_USERNAME,
          pwd: process.env.BROWSER_STACK_ACCESS_KEY
        },
        // Custom indicator of vendor service.
        isBrowserStack: true
      },
      /*jshint camelcase:false*/
      "safari-mac": {
        desiredCapabilities: {
          browserName: "safari",
          os: "OS X",
          os_version: "Mavericks"
        }
      },
      "chrome-win7": {
        desiredCapabilities: {
          browserName: "chrome",
          os: "WINDOWS",
          os_version: "7"
        }
      }
      /*jshint camelcase:true*/
    },
  }
};

@@ -24,32 +24,201 @@
  */%0A
-var path = require(%22path
+// Windows: Phantom path inference.%0Avar path = require(%22path%22);%0Avar PHANTOM_PATH = process.platform === %22win32%22 && path.join(__dirname,%0A  %22../../node_modules/phantomjs/lib/phantom/phantomjs.exe
 %22);%0A
@@ -1643,25 +1643,62 @@
  start: true
+,%0A          phantomPath: PHANTOM_PATH
 %0A
-
         %7D%0A  
@@ -1746,32 +1746,32 @@
 Capabilities: %7B%0A
+
           browse
@@ -1793,246 +1793,8 @@
 js%22%0A
-        %7D,%0A        server: %7B%0A          // Add path to NPM-installed Phantom EXE on Windows.%0A          phantomPath: process.platform === %22win32%22 && path.join(__dirname,%0A            %22../../node_modules/phantomjs/lib/phantom/phantomjs.exe%22)%0A
     

Move phantompath to local defaults.