Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[[CHORE]] Relocate development dependencies
The `phantom` and `phantomjs-prebuilt` modules cannot be installed in legacy versions of Node.js because during their installation procedure, they import code which uses ES2015 language features. When executed in legacy versions of Node.js, this causes a syntax error, interrupting installation and making it impossible to execute the project's tests. A previous commit [1] addressed this issue by marking the dependencies as "optional." This allowed the installation procedure to fail, and because the packages are only necessary in the latest release of Node.js, the relevant tests could execute as expected. Unfortunately, this modification had an unintended effect on consumers of JSHint: it forced them to also install the aforementioned packages. Because these packages are only necessary when contributing to JSHint (not when using it) and because they include large binary assets, this had a non-trivial impact on the time and disk space required to install JSHint. Revert the previous change, marking the packages as "dev dependencies" once again. Ensure that the project's tests can continue to execute in legacy versions of Node.js by introducing a script that removes the offending packages prior to installation on those platforms. [1] 2f6ac13
- Loading branch information
1 parent
d5c1a00
commit f70250b
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict" | ||
/** | ||
* Some of this project's development dependencies cannot be successfully | ||
* installed in legacy versions of Node.js. This module removes development | ||
* dependencies from the project's npm package manifest so that the `npm` | ||
* utility does not attempt to install them in a subsequent execution of `npm | ||
* install. Although the `npm` utility offers a "remove" command, that command | ||
* can remove only one package per invocation and triggers installation of all | ||
* other packages. This script allows mutliple packages to be removed prior to | ||
* installation. | ||
*/ | ||
|
||
var path = require("path"); | ||
var fs = require("fs"); | ||
var manifestLocation = path.join(__dirname, "..", "package.json"); | ||
var manifest = require(manifestLocation); | ||
var packageNames = process.argv.slice(2); | ||
var newContents; | ||
|
||
packageNames.forEach(function(packageName) { | ||
if (!manifest.devDependencies[packageName]) { | ||
throw new Error("Could not locate development dependency named \"" + packageName + "\""); | ||
} | ||
|
||
delete manifest.devDependencies[packageName]; | ||
}); | ||
|
||
newContents = JSON.stringify(manifest, null, 2); | ||
|
||
fs.writeFile(manifestLocation, newContents, function(err) { | ||
if (err) { | ||
throw new Error(err); | ||
} | ||
|
||
console.log("Successfully removed packages. New contents:"); | ||
console.log(newContents.replace(/(^|\n)/g, "$1> ")); | ||
}); |