Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Ability to specify PhantomJS version #317

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ Another option is to use PATH variable `PHANTOMJS_CDNURL`.
PHANTOMJS_CDNURL=http://cnpmjs.org/downloads npm install phantomjs
```

### Custom PhantomJS version
A custom version number of Phantom can be used by suppling the following CLI argument

```shell
npm install phantomjs --phantomjs_version=2.0.0
```

Running
-------
Expand Down
7 changes: 4 additions & 3 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ var util = require('util')
var which = require('which')

var cdnUrl = process.env.npm_config_phantomjs_cdnurl || process.env.PHANTOMJS_CDNURL || 'https://bitbucket.org/ariya/phantomjs/downloads'
var downloadUrl = cdnUrl + '/phantomjs-' + helper.version + '-'
var phantomVersion = process.env.npm_config_phantomjs_version || process.env.PHANTOMJS_VERSION || helper.version
var downloadUrl = cdnUrl + '/phantomjs-' + phantomVersion + '-'

var originalPath = process.env.PATH

Expand Down Expand Up @@ -81,7 +82,7 @@ whichDeferred.promise
})
.then(function (stdout) {
var version = stdout.trim()
if (helper.version == version) {
if (phantomVersion == version) {
writeLocationFile(phantomPath);
console.log('PhantomJS is already installed at', phantomPath + '.')
exit(0)
Expand Down Expand Up @@ -342,7 +343,7 @@ function copyIntoPlace(extractedPath, targetPath) {
var files = fs.readdirSync(extractedPath)
for (var i = 0; i < files.length; i++) {
var file = path.join(extractedPath, files[i])
if (fs.statSync(file).isDirectory() && file.indexOf(helper.version) != -1) {
if (fs.statSync(file).isDirectory() && file.indexOf(phantomVersion) != -1) {
console.log('Copying extracted folder', file, '->', targetPath)
return kew.nfcall(fs.move, file, targetPath)
}
Expand Down