-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(check-peer-dependencies-optional-dependency): Added a workaround…
… for yarn swallowing postinstall script output
- Loading branch information
1 parent
927fc53
commit a9c9fdf
Showing
3 changed files
with
49 additions
and
0 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 |
---|---|---|
|
@@ -86,3 +86,6 @@ Searching for solutions: | |
yarn upgrade @angular/[email protected] | ||
``` | ||
|
||
## Running as postinstall script using `yarn` package manager | ||
|
||
Please see [check-peer-dependencies-optional-dependency](https://github.com/christopherthielen/check-peer-dependencies/tree/master/packages/check-peer-dependencies-optional-dependency) |
36 changes: 36 additions & 0 deletions
36
packages/check-peer-dependencies-optional-dependency/README.md
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,36 @@ | ||
# check-peer-dependencies-optional-dependency | ||
|
||
## This is a hack to make check-peer-dependency output visible as a postinstall script when using yarn. | ||
|
||
### Motivation | ||
|
||
I wanted to create a meta-package that provides a set of peerDependencies to downstream projects. | ||
I wanted to run `check-peer-dependencies` as a `postinstall` script to inform users which dependencies are not met and offer a solution. | ||
|
||
### Problem | ||
|
||
By default, `yarn` package manager hides output from postinstall scripts. | ||
I noticed, however, that output from `optionalDependencies` is visible. | ||
|
||
### Using | ||
|
||
To run `check-peer-dependencies` as when your package is installed, add `check-peer-dependencies-optional-dependency` as an optional dependency. | ||
This package has a `postinstall` script which invokes `check-peer-dependencies`. | ||
|
||
``` | ||
{ | ||
"name": "my-installable-package", | ||
... | ||
"dependencies": { | ||
... | ||
"check-peer-dependencies": "latest" | ||
}, | ||
"peerDependencies": { | ||
"this-package-should-be-installed-downstream": "10.0.0" | ||
}, | ||
"optionalDependencies: { | ||
"check-peer-dependencies-optional-dependency": "latest" | ||
} | ||
} | ||
``` | ||
|
10 changes: 10 additions & 0 deletions
10
packages/check-peer-dependencies-optional-dependency/package.json
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,10 @@ | ||
{ | ||
"name": "check-peer-dependencies-optional-dependency", | ||
"version": "1.0.0", | ||
"description": "Add this module as an optional dependency to check peer dependencies as a postinstall script (yarn)", | ||
"author": "Chris Thielen", | ||
"license": "MIT", | ||
"scripts": { | ||
"postinstall": "npx check-peer-dependencies" | ||
} | ||
} |