Skip to content

Commit

Permalink
Adds default location for MacOS browsers. Should close #1
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Nov 17, 2012
1 parent 37cb845 commit ec221eb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Empty file added bin/launchpad
Empty file.
9 changes: 0 additions & 9 deletions examples/allBrowsersTest.js

This file was deleted.

Empty file added examples/browserstack.js
Empty file.
Empty file added examples/local.js
Empty file.
17 changes: 13 additions & 4 deletions lib/local/platform/macos.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var plist = require('plist');
var path = require('path');
var async = require('async');
var _ = require('underscore');
var fs = require('fs');

var supportedBrowsers = exports.supported = [
{
Expand All @@ -11,23 +12,26 @@ var supportedBrowsers = exports.supported = [
plistPath : 'Contents/Info.plist',
command : 'open',
process : 'Google Chrome',
versionKey : 'KSVersion'
versionKey : 'KSVersion',
defaultLocation : '/Applications/Google Chrome.app'
},
{
name : 'firefox',
pathQuery : 'mdfind \'kMDItemDisplayName == "Firefox" && kMDItemKind == Application\'',
plistPath : 'Contents/Info.plist',
command : 'open',
process : 'firefox',
versionKey : 'CFBundleGetInfoString'
versionKey : 'CFBundleGetInfoString',
defaultLocation : '/Applications/Firefox.app'
},
{
name : 'opera',
pathQuery : 'mdfind \'kMDItemDisplayName == "Opera" && kMDItemKind == Application\'',
plistPath : 'Contents/Info.plist',
command : 'open',
process : 'Opera',
versionKey : 'CFBundleShortVersionString'
versionKey : 'CFBundleShortVersionString',
defaultLocation : '/Applications/Opera.app'
},
{
name : 'phantom',
Expand All @@ -41,7 +45,8 @@ var supportedBrowsers = exports.supported = [
plistPath : 'Contents/version.plist',
command : 'open',
process : 'Safari',
versionKey : 'CFBundleShortVersionString'
versionKey : 'CFBundleShortVersionString',
defaultLocation : '/Applications/Safari.app'
}
];

Expand All @@ -53,6 +58,10 @@ var browsers = supportedBrowsers.map(function (browser) {
if (err) return callback(err);

if (!stdout.length) {
// Not found using mdfind, let's see if the standard path exists
if(browser.defaultLocation && fs.existsSync(browser.defaultLocation)) {
return callback(null, browser.defaultLocation);
}
return callback(null, null);
}

Expand Down

0 comments on commit ec221eb

Please sign in to comment.