Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix to support linux #9

Closed
wants to merge 3 commits into from

3 participants

@diramazioni

Hello, I've made a first fix to make the pid detection and chrome work under ubuntu.

It would be nice if firefox were opening a new tab (-new-tab) if is detected that is already running. This works and is the default behavior in chrome.

~~
Eli

@daffl
Collaborator

Yay, first pull request, thanks! Forgot that we are using the PID check to see if the browser is already running. This won't work in Windows either.

Do you know what Firefox does if you start it with -new-tab and it isn't running yet? If it just starts up we could just add it as a default parameter.

@ekryski
Owner

I can check it out tonight when I get home. Thanks for the pull request! This stuff is really hard to write tests for so if you find bugs, keep them coming.

@diramazioni

it works! if firefox is already running it start a new tab otherwise it start a new instance of firefox

@diramazioni
@ekryski
Owner

Changing this does indeed work on Linux but breaks stopping an instance on Mac OS X. I'll fix it up this evening.

@ekryski
Owner

Ok I finally got around to reviewing this. Thanks again for the pull request. There are two problems:

  • The change to detecting the PID works on Linux but breaks closing browsers on Mac OS X.
  • Starting up a Firefox instance with --new-tab works great but the instance no longer gets killed if it is already open.
@ekryski ekryski closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
6 examples/local.js
@@ -3,16 +3,16 @@ var launch = require('../lib');
launch.local(function(err, launcher) {
// User the launcher api
launcher('http://github.com/ekryski', {
- browser : 'chrome'
+ browser : 'chromium'
}, function(error, worker) {
if(error) {
console.log('Error:', error);
return;
}
- console.log('Launched Safari. Process id:', worker.id);
+ console.log('Launched chromium. Process id:', worker.id);
setTimeout(function() {
worker.stop(function() {
- console.log('Safari stopped');
+ console.log('chromium stopped');
});
}, 10000);
});
View
2  lib/local/instance.js
@@ -4,7 +4,7 @@ var EventEmitter = require('events').EventEmitter;
var getProcessId = function(name, callback) {
// Get the process with the given name if it is running
- exec("ps -clx | grep '" + name + "$' | awk '{print $2}' | head -1", function(err, stdout) {
+ exec("ps ax | grep '" + name + "$' | awk '{print $2}' | head -1", function(err, stdout) {
var pid = stdout.trim();
if(!pid) {
return callback(new Error('There does not seem to be a ' + name + ' process running'));
View
7 lib/local/platform/unix.js
@@ -10,9 +10,14 @@ var supportedBrowsers = exports.supported = [
process : 'chrome'
},
{
+ name : 'chromium',
+ pathQuery : 'which chromium-browser',
+ process : 'chrome'
+ },
+ {
name : 'firefox',
pathQuery : 'which firefox',
- process : 'firefox'
+ process : 'firefox --new-tab'
},
{
name : 'opera',
Something went wrong with that request. Please try again.