Custom binary name name #1

Merged
merged 3 commits into from Jul 11, 2012

Projects

None yet

1 participant

@sethmcl
Owner
sethmcl commented Jul 11, 2012

This patch allows the user to specify where to find the phantomjs
executable, rather than forcing the use of the 'phantomjs' executable
which is in the path.

For example, let's say you have two versions of phantomjs installed at
these locations:

/home/user/tools/phantomjs/v1.3/bin/phantomjs
/home/user/tools/phantomjs/v1.6/bin/phantomjs

You can choose whether you want to use version 1.3 or 1.6 when calling
phantom.create() with a new, optional, parameter:

  phantom.create(cb, '/home/user/tools/phantomjs/v1.6/bin/phantomjs')

If this parameter is not specified, then a default of 'phantomjs' will
be used (which will just use whichever phantomjs binary is in your
path).

Example usage

// using the new parameter
var pathToPhantomJsBinary = '/home/user/tools/phantomjs/v1.6/bin/phantomjs';

phantom.create(function(ph) {
  return ph.createPage(function(page) {
    return page.open(loadUrl, function(status) {
      return page.evaluate((function() {
        return document.title;
      }), function(result) {
        return ph.exit();
      });
    });
  });
}, pathToPhantomJsBinary);

// default behavior still works
phantom.create(function(ph) {
  return ph.createPage(function(page) {
    return page.open(loadUrl, function(status) {
      return page.evaluate((function() {
        return document.title;
      }), function(result) {
        return ph.exit();
      });
    });
  });
});
added some commits Jul 10, 2012
@sethmcl Ignoring node_modules 2bd1aea
@sethmcl This patch allows the user to specify where to find the phantomjs
executable, rather than forcing the use of the 'phantomjs' executable
which is in the path.

For example, let's say you have two versions of phantomjs installed at
these locations:

`/home/user/tools/phantomjs/v1.3/bin/phantomjs`
`/home/user/tools/phantomjs/v1.6/bin/phantomjs`

You can choose whether you want to use version 1.3 or 1.6 when calling
phantom.create() with a new, optional, parameter:

```javascript
  phantom.create(cb, '/home/user/tools/phantomjs/v1.6/bin/phantomjs')
```

If this parameter is not specified, then a default of 'phantomjs' will
be used (which will just use whichever phantomjs binary is in your
path).

__Example usage__
```javascript
// using the new parameter
var pathToPhantomJsBinary = '/home/user/tools/phantomjs/v1.6/bin/phantomjs';

phantom.create(function(ph) {
  return ph.createPage(function(page) {
    return page.open(loadUrl, function(status) {
      return page.evaluate((function() {
        return document.title;
      }), function(result) {
        return ph.exit();
      });
    });
  });
}, pathToPhantomJsBinary);

// default behavior still works
phantom.create(function(ph) {
  return ph.createPage(function(page) {
    return page.open(loadUrl, function(status) {
      return page.evaluate((function() {
        return document.title;
      }), function(result) {
        return ph.exit();
      });
    });
  });
});
```
68afdd6
@sethmcl Removing console.log() statement which was being used for debugging 6f482ad
@sethmcl sethmcl merged commit 272f6e4 into master Jul 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment