-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve overrides from root package
NPM 8.3.0 introduced the `overrides` key in package.json, which allows you to customize the dependencies of any (or all) of your project's dependencies. hydrate should respect the root project's overrides.
- Loading branch information
Showing
2 changed files
with
19 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
let { existsSync, readFileSync } = require('fs') | ||
let { join } = require('path') | ||
|
||
// Get params from root project that should be preserved in hydrated package.json | ||
module.exports = function getRootParams ({ inv }) { | ||
let root = inv._project.cwd | ||
let packageJson = join(root, 'package.json') | ||
|
||
let package = existsSync(packageJson) && JSON.parse(readFileSync(packageJson)) || {} | ||
|
||
let result = {} | ||
if (package.overrides) | ||
result.overrides = package.overrides | ||
|
||
return result | ||
} |
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