Skip to content

Commit

Permalink
fix: correct Chrome path on Windows
Browse files Browse the repository at this point in the history
Checks for Chrome in the default location on windows taking into account
32 and 64 bit machines.  Falls back to the version in the user's
profile.

Closes #2
  • Loading branch information
Joe Doyle authored and vojtajina committed Nov 22, 2013
1 parent ee0958e commit 9ebd997
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions index.js
@@ -1,3 +1,6 @@
var os = require('os'),
fs = require('fs');

var ChromeBrowser = function(baseBrowserDecorator, args) {
baseBrowserDecorator(this);

Expand All @@ -22,7 +25,7 @@ ChromeBrowser.prototype = {
DEFAULT_CMD: {
linux: 'google-chrome',
darwin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
win32: process.env.LOCALAPPDATA + '\\Google\\Chrome\\Application\\chrome.exe'
win32: windowsChromePath('\\Google\\Chrome\\Application\\chrome.exe')
},
ENV_CMD: 'CHROME_BIN'
};
Expand All @@ -46,13 +49,26 @@ ChromeCanaryBrowser.prototype = {
DEFAULT_CMD: {
linux: 'google-chrome-canary',
darwin: '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
win32: process.env.LOCALAPPDATA + '\\Google\\Chrome SxS\\Application\\chrome.exe'
win32: windowsChromePath('\\Google\\Chrome SxS\\Application\\chrome.exe')
},
ENV_CMD: 'CHROME_CANARY_BIN'
};

ChromeCanaryBrowser.$inject = ['baseBrowserDecorator', 'args'];

var windowsChromePath = function(chromeExe) {
if (os.platform() !== 'win32') {
return '';
}

var globalInstall = os.arch() === 'x64' ? process.env['ProgramFiles(x86)'] : process.env.ProgramFiles;

if (fs.existsSync(globalInstall + chromeExe)) {
return globalInstall + chromeExe;
}

return process.env.LOCALAPPDATA + chromeExe;
}

// PUBLISH DI MODULE
module.exports = {
Expand Down

0 comments on commit 9ebd997

Please sign in to comment.