Skip to content

Commit

Permalink
[[FIX]] Preserve functionality in "legacy" Node.js
Browse files Browse the repository at this point in the history
A recent minor release of the npm module `request` has introduced
breaking changes for Node.js versions 0.10 and 0.12. Because JSHint
depends on this module transitively through one of its
`devDependencies`, this interferes with the project's ability to verify
its own correctness in the effected environments.

Allow JSHint to be installed in legacy environments by specifying the
effected dependencies as "optional." These dependencies are only
required by tests for the PhantomJS platform, and those tests can be
orchestrated from a single actively-maintained version of Node.js
without effecting coverage.
  • Loading branch information
jugglinmike authored and rwaldron committed Nov 21, 2017
1 parent a11d631 commit 2f6ac13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@
"jscs": "1.11.x",
"mock-stdin": "0.3.x",
"nodeunit": "0.9.x",
"phantom": "~4.0.1",
"phantomjs-prebuilt": "~2.1.7",
"regenerate": "1.2.x",
"sinon": "1.12.x",
"unicode-6.3.0": "0.1.x"
},

"optionalDependencies": {
"phantom": "~4.0.1",
"phantomjs-prebuilt": "~2.1.7"
},

"license": "(MIT AND JSON)",

"preferGlobal": true,
Expand Down
15 changes: 13 additions & 2 deletions tests/browser.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
"use strict";

var phantom = require("phantom");
var phantom, phantomJsPrebuilt;
try {
phantom = require("phantom");
phantomJsPrebuilt = require("phantomjs-prebuilt");
} catch (err) {
throw new Error(
"Unable to run tests in PhantomJS because the required dependencies are " +
"not available. Please note that JSHint does not support development " +
"using versions of Node.js which are no longer maintained."
);
}

var createTestServer = require("./helpers/browser/server");
var options = {
/**
* The `phantom` module provides a Node.js API for the PhantomJS binary,
* while the `phantomjs` module includes the binary itself.
*/
phantomPath: require("phantomjs-prebuilt").path
phantomPath: phantomJsPrebuilt.path
};
var port = process.env.NODE_PORT || 8045;
var ph;
Expand Down

0 comments on commit 2f6ac13

Please sign in to comment.