Skip to content

Commit a9c9fdf

Browse files
feat(check-peer-dependencies-optional-dependency): Added a workaround for yarn swallowing postinstall script output
1 parent 927fc53 commit a9c9fdf

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,6 @@ Searching for solutions:
8686
yarn upgrade @angular/[email protected]
8787
```
8888

89+
## Running as postinstall script using `yarn` package manager
90+
91+
Please see [check-peer-dependencies-optional-dependency](https://github.com/christopherthielen/check-peer-dependencies/tree/master/packages/check-peer-dependencies-optional-dependency)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# check-peer-dependencies-optional-dependency
2+
3+
## This is a hack to make check-peer-dependency output visible as a postinstall script when using yarn.
4+
5+
### Motivation
6+
7+
I wanted to create a meta-package that provides a set of peerDependencies to downstream projects.
8+
I wanted to run `check-peer-dependencies` as a `postinstall` script to inform users which dependencies are not met and offer a solution.
9+
10+
### Problem
11+
12+
By default, `yarn` package manager hides output from postinstall scripts.
13+
I noticed, however, that output from `optionalDependencies` is visible.
14+
15+
### Using
16+
17+
To run `check-peer-dependencies` as when your package is installed, add `check-peer-dependencies-optional-dependency` as an optional dependency.
18+
This package has a `postinstall` script which invokes `check-peer-dependencies`.
19+
20+
```
21+
{
22+
"name": "my-installable-package",
23+
...
24+
"dependencies": {
25+
...
26+
"check-peer-dependencies": "latest"
27+
},
28+
"peerDependencies": {
29+
"this-package-should-be-installed-downstream": "10.0.0"
30+
},
31+
"optionalDependencies: {
32+
"check-peer-dependencies-optional-dependency": "latest"
33+
}
34+
}
35+
```
36+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "check-peer-dependencies-optional-dependency",
3+
"version": "1.0.0",
4+
"description": "Add this module as an optional dependency to check peer dependencies as a postinstall script (yarn)",
5+
"author": "Chris Thielen",
6+
"license": "MIT",
7+
"scripts": {
8+
"postinstall": "npx check-peer-dependencies"
9+
}
10+
}

0 commit comments

Comments
 (0)