Skip to content

Commit

Permalink
Drop support for PhantomJS (fixes #33) (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry authored and vweevers committed May 31, 2019
1 parent 1e0502a commit ca6448d
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 117 deletions.
82 changes: 0 additions & 82 deletions lib/browsers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
'use strict'

const path = require('path')
const existent = require('existent')
const debug = require('debug')('win-detect-browsers')
const ffChannel = require('./firefox-release-channel')
const resolve = require('resolve')

exports.chrome = {
find: function () {
Expand Down Expand Up @@ -121,84 +117,6 @@ exports.maxthon = {
}
}

exports.phantomjs = {
// Without .exe suffix, so phantomjs.cmd can be found in PATH
bin: 'phantomjs',

find: function () {
this.inPath()
this.env('PHANTOMJS_BIN')

const cwd = process.cwd()
const cb = this.plan(1)
const self = this

// 2.x
resolve('phantomjs-prebuilt', { basedir: cwd }, function (err, mod) {
if (!err) return self.found(require(mod).path, 'phantomjs-prebuilt', cb)

// 1.x
resolve('phantomjs', { basedir: cwd }, function (err, mod) {
if (!err) self.found(require(mod).path, 'phantomjs', cb)
else cb()
})
})
},

pre: function (file, done, _noRecursion) {
if (!isCmd(file)) return done(file)

// If installed by nodejs module, we can get the executable
// path from the module. The module also provides a
// version number, but we ignore that to keep things simple.

const mod1x = 'node_modules/phantomjs/lib/phantomjs.js'
const mod2x = 'node_modules/phantomjs-prebuilt/lib/phantomjs.js'
const global = '..'
const local = '../../..'
const self = this

const locations = [
path.resolve(file, global, mod1x),
path.resolve(file, local, mod1x),
path.resolve(file, global, mod2x),
path.resolve(file, local, mod2x)
]

next()

function next () {
if (!locations.length) {
debug('Could not resolve "%s" to module', file)
return done()
}

const loc = locations.pop()

existent(loc, function (err) {
if (!err) getBinary(loc)
else next()
})
}

function isCmd (path) {
return path.slice(-4).toLowerCase() === '.cmd'
}

function getBinary (mod) {
const path = require(mod).path

// a local module can point to global installation
if (isCmd(path)) {
if (_noRecursion) return done()
return self.pre(path, done, true)
}

done(path)
}
}
}

exports.opera = {
bin: 'Launcher.exe',

Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"pe-machine-type": "~1.0.0",
"pretty-tree": "~1.0.0",
"registry-js": "~1.4.0",
"resolve": "~1.11.0",
"which": "~1.3.0",
"win-version-info": "~2.1.0",
"windows-env": "~1.0.1",
Expand All @@ -49,7 +48,6 @@
"chromium",
"canary",
"firefox",
"phantomjs",
"ie",
"internet-explorer",
"safari",
Expand Down
23 changes: 2 additions & 21 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# win-detect-browsers

**Fast and native browser detection on Windows. Detects installed versions of [Beaker](https://beakerbrowser.com/), [Brave](https://brave.com/), [Chrome](https://www.google.com/chrome/), [Chromium](https://www.chromium.org/), [Firefox](https://www.mozilla.org/en-US/firefox/), [Internet Explorer](https://en.wikipedia.org/wiki/Internet_Explorer), [Maxthon](http://www.maxthon.com/), [Opera](https://www.opera.com/), [PhantomJS](http://phantomjs.org/), [Safari](https://www.apple.com/safari/) and [Yandex](https://browser.yandex.com/).**
**Fast and native browser detection on Windows. Detects installed versions of [Beaker](https://beakerbrowser.com/), [Brave](https://brave.com/), [Chrome](https://www.google.com/chrome/), [Chromium](https://www.chromium.org/), [Firefox](https://www.mozilla.org/en-US/firefox/), [Internet Explorer](https://en.wikipedia.org/wiki/Internet_Explorer), [Maxthon](http://www.maxthon.com/), [Opera](https://www.opera.com/), [Safari](https://www.apple.com/safari/) and [Yandex](https://browser.yandex.com/).**

[![npm status](http://img.shields.io/npm/v/win-detect-browsers.svg)](https://www.npmjs.org/package/win-detect-browsers)
[![Build status](https://img.shields.io/appveyor/ci/vweevers/win-detect-browsers.svg)](https://ci.appveyor.com/project/vweevers/win-detect-browsers)
Expand Down Expand Up @@ -52,7 +52,7 @@ detect(['chrome', 'firefox'], function (err, browsers) {

Each `result` is an object with the following properties:

- `name` (string): `chrome`, `chromium`, `firefox`, `phantomjs`, `ie`, `safari`, `opera`, `maxthon` or `yandex`
- `name` (string): `chrome`, `chromium`, `firefox`, `ie`, `safari`, `opera`, `maxthon` or `yandex`
- `path` (string): absolute path to executable
- `version` (string)
- `arch` (string): CPU type the executable was built for: `amd64`, `i386` or [other](https://github.com/vweevers/pe-machine-type#types);
Expand Down Expand Up @@ -92,10 +92,6 @@ On Windows 10 with `--summary`:
<details><summary>Click to expand</summary>

```
PHANTOMJS 2 32-bit
├── Path: C:\Users\vweevers\AppData\Roaming\nvm\v10.0.0\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe
└── Version: 2.1.1.0
IE 11 64-bit
├── Path: C:\Program Files\Internet Explorer\iexplore.exe
└── Version: 11.0.17134.1
Expand Down Expand Up @@ -143,21 +139,6 @@ On Windows 10 with `--json`:

```json
[
{
"name": "phantomjs",
"path": "C:\\Users\\vweevers\\AppData\\Roaming\\nvm\\v10.0.0\\node_modules\\phantomjs-prebuilt\\lib\\phantom\\bin\\phantomjs.exe",
"version": "2.1.1.0",
"arch": "i386",
"info": {
"FileVersion": "2.1.1.0",
"FileDescription": "PhantomJS is a headless WebKit with JavaScript API",
"LegalCopyright": "Copyright (C) Ariya Hidayat 2012",
"OriginalFilename": "phantomjs.exe",
"ProductName": "PhantomJS",
"ProductVersion": "2.1.1",
"CompanyName": "PhantomJS"
}
},
{
"name": "ie",
"path": "C:\\Program Files\\Internet Explorer\\iexplore.exe",
Expand Down
12 changes: 0 additions & 12 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// Opt-in functional tests:
//
// --opera: requires Opera Stable, Beta and Developer
// --phantomjs: requires `npm i phantomjs -g`
// --canary: requires Chrome Canary

process.stderr.setMaxListeners(100)
Expand All @@ -27,7 +26,6 @@ const registry = require('./lib/registry')
const argv = require('yargs')
.boolean('opera')
.boolean('canary')
.boolean('phantomjs')
.argv

test('find methods', function (t) {
Expand Down Expand Up @@ -401,16 +399,6 @@ maybe(argv.opera)('detect all opera versions', function (t) {
})
})

maybe(argv.phantomjs)('detect phantomjs', function (t) {
t.plan(3)

detect('phantomjs', function (err, results) {
t.ifError(err, 'no error')
t.equal(results[0].name, 'phantomjs')
t.ok(hasVersion(results[0]), 'has version')
})
})

test('concurrency', function (t) {
const n = 5

Expand Down

0 comments on commit ca6448d

Please sign in to comment.