-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: don't remove optional dependencies in clean-shrinkwrap.js (#1551)
If we include a platform specific optional dependency in the shrinkwrap file, then npm will insist in installing it even if the platform doesn't match. As a solution, we figured out we can avoid putting this platform specific optional dependencies in the npm-shrinkwrap.json file. In order to do this, we currently have a script called `clean-shrinkwrap.js` that runs *before* any `npm shrinkwrap` file (its a `preshrinkwrap` npm script) that deletes all the platform specific modules we know about using `npm rm`. The problem with this approach is that `npm rm` will remove the module's code from `node_modules`, which means that if we run `npm shrinkwrap`, we will lose certain optional dependencies, that may be needed at a later stage. The solution is to modify the `clean-shrinkwrap.js` script to parse `npm-shrinkwrap.json`, and manually delete the entries that we want to omit. Also, the script needs to be run *after* `npm shrinkwrap`, so we change the npm script name to `postshrinkwrap`. Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
3 changed files
with
253 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,21 +19,17 @@ | |
"scripts": { | ||
"test": "make test", | ||
"start": "electron lib/start.js", | ||
"preshrinkwrap": "node ./scripts/clean-shrinkwrap.js", | ||
"postshrinkwrap": "node ./scripts/clean-shrinkwrap.js", | ||
"configure": "node-gyp configure", | ||
"build": "node-gyp build", | ||
"install": "node-gyp rebuild" | ||
}, | ||
"author": "Resin Inc. <[email protected]>", | ||
"license": "Apache-2.0", | ||
"shrinkwrapIgnore": [ | ||
"macos-alias", | ||
"fs-xattr", | ||
"ds-store", | ||
"appdmg", | ||
"7zip-bin-mac", | ||
"7zip-bin-win", | ||
"7zip-bin-linux" | ||
"platformSpecificDependencies": [ | ||
[ "7zip-bin-mac" ], | ||
[ "7zip-bin-win" ], | ||
[ "7zip-bin-linux" ] | ||
], | ||
"dependencies": { | ||
"angular": "1.6.3", | ||
|
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