Skip to content

Commit cdb0136

Browse files
committed
upgrade prettier + reformat readme
1 parent 9bee26a commit cdb0136

File tree

4 files changed

+80
-42
lines changed

4 files changed

+80
-42
lines changed

.prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"semi": false,
3-
"trailingComma": "all"
3+
"trailingComma": "all",
4+
"proseWrap": "always"
45
}

README.md

+73-36
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img src="./patch-package.svg" width="80%" alt="patch-package" />
2+
<img src="https://raw.githubusercontent.com/ds300/patch-package/master/patch-package.svg" width="80%" alt="patch-package" />
33
</p>
44

55
`patch-package` lets app authors instantly make and keep fixes to npm
@@ -17,11 +17,11 @@ git add patches/some-package+3.14.15.patch
1717
git commit -m "fix brokenFile.js in some-package"
1818
```
1919

20-
Patches created by `patch-package` are automatically and gracefully applied
21-
when you use `npm`(>=5) or `yarn`.
20+
Patches created by `patch-package` are automatically and gracefully applied when
21+
you use `npm`(>=5) or `yarn`.
2222

23-
No more waiting around for pull requests to be merged and published.
24-
No more forking repos just to fix that one tiny thing preventing your app from working.
23+
No more waiting around for pull requests to be merged and published. No more
24+
forking repos just to fix that one tiny thing preventing your app from working.
2525

2626
## Set-up
2727

@@ -39,25 +39,32 @@ Then
3939

4040
npm i patch-package
4141

42-
You can use `--save-dev` if you don't need to run npm in production, e.g. if you're making a web frontend.
42+
You can use `--save-dev` if you don't need to run npm in production, e.g. if
43+
you're making a web frontend.
4344

4445
### yarn
4546

4647
yarn add patch-package postinstall-postinstall
4748

48-
You can use `--dev` if you don't need to run yarn in production, e.g. if you're making a web frontend.
49+
You can use `--dev` if you don't need to run yarn in production, e.g. if you're
50+
making a web frontend.
4951

50-
To understand why yarn needs the `postinstall-postinstall` package see: [Why use postinstall-postinstall](#why-use-postinstall-postinstall-with-yarn)
52+
To understand why yarn needs the `postinstall-postinstall` package see:
53+
[Why use postinstall-postinstall](#why-use-postinstall-postinstall-with-yarn)
5154

5255
### yarn workspaces
5356

54-
Same as for yarn ☝️ Note that if you want to patch un-hoisted packages you'll need to repeat the setup process for the child package. Also make sure you're in the child package directory when you run `patch-package` to generate the patch files.
57+
Same as for yarn ☝️ Note that if you want to patch un-hoisted packages you'll
58+
need to repeat the setup process for the child package. Also make sure you're in
59+
the child package directory when you run `patch-package` to generate the patch
60+
files.
5561

5662
## Usage
5763

5864
### Making patches
5965

60-
First make changes to the files of a particular package in your node_modules folder, then run
66+
First make changes to the files of a particular package in your node_modules
67+
folder, then run
6168

6269
yarn patch-package package-name
6370

@@ -67,29 +74,31 @@ or use npx (included with `npm > 5.2`)
6774

6875
where `package-name` matches the name of the package you made changes to.
6976

70-
If this is the first time you've used `patch-package`, it will create a folder called `patches` in
71-
the root dir of your app. Inside will be a file called `package-name+0.44.0.patch` or something,
72-
which is a diff between normal old `package-name` and your fixed version. Commit this to share the fix with your team.
77+
If this is the first time you've used `patch-package`, it will create a folder
78+
called `patches` in the root dir of your app. Inside will be a file called
79+
`package-name+0.44.0.patch` or something, which is a diff between normal old
80+
`package-name` and your fixed version. Commit this to share the fix with your
81+
team.
7382

7483
#### Options
7584

7685
- `--use-yarn`
7786

78-
By default, patch-package checks whether you use npm or yarn based on
79-
which lockfile you have. If you have both, it uses npm by default.
80-
Set this option to override that default and always use yarn.
87+
By default, patch-package checks whether you use npm or yarn based on which
88+
lockfile you have. If you have both, it uses npm by default. Set this option
89+
to override that default and always use yarn.
8190

8291
- `--exclude <regexp>`
8392

84-
Ignore paths matching the regexp when creating patch files.
85-
Paths are relative to the root dir of the package to be patched.
93+
Ignore paths matching the regexp when creating patch files. Paths are relative
94+
to the root dir of the package to be patched.
8695

8796
Default value: `package\\.json$`
8897

8998
- `--include <regexp>`
9099

91-
Only consider paths matching the regexp when creating patch files.
92-
Paths are relative to the root dir of the package to be patched.
100+
Only consider paths matching the regexp when creating patch files. Paths are
101+
relative to the root dir of the package to be patched.
93102

94103
Default value: `.*`
95104

@@ -103,7 +112,9 @@ which is a diff between normal old `package-name` and your fixed version. Commit
103112

104113
#### Nested packages
105114

106-
If you are trying to patch a package at, e.g. `node_modules/package/node_modules/another-package` you can just put a `/` between the package names:
115+
If you are trying to patch a package at, e.g.
116+
`node_modules/package/node_modules/another-package` you can just put a `/`
117+
between the package names:
107118

108119
npx patch-package package/another-package
109120

@@ -113,7 +124,8 @@ It works with scoped packages too
113124

114125
### Updating patches
115126

116-
Use exactly the same process as for making patches in the first place, i.e. make more changes, run patch-package, commit the changes to the patch file.
127+
Use exactly the same process as for making patches in the first place, i.e. make
128+
more changes, run patch-package, commit the changes to the patch file.
117129

118130
### Applying patches
119131

@@ -125,9 +137,12 @@ Run `patch-package` without arguments to apply all patches in your project.
125137

126138
Un-applies all patches.
127139

128-
Note that this will fail if the patched files have changed since being patched. In that case, you'll probably need to re-install `node_modules`.
140+
Note that this will fail if the patched files have changed since being
141+
patched. In that case, you'll probably need to re-install `node_modules`.
129142

130-
This option was added to help people using CircleCI avoid [an issue around caching and patch file updates](https://github.com/ds300/patch-package/issues/37) but might be useful in other contexts too.
143+
This option was added to help people using CircleCI avoid
144+
[an issue around caching and patch file updates](https://github.com/ds300/patch-package/issues/37)
145+
but might be useful in other contexts too.
131146

132147
- `--patch-dir`
133148

@@ -145,22 +160,32 @@ or `patch` in unixy environments:
145160

146161
### Dev-only patches
147162

148-
If you deploy your package to production (e.g. your package is a server) then any patched `devDependencies` will not be present when patch-package runs in production. It will happily ignore those patch files if the package to be patched is listed directly in the `devDependencies` of your package.json. If it's a transitive dependency patch-package can't detect that it is safe to ignore and will throw an error. To fix this, mark patches for transitive dev dependencies as dev-only by renaming from, e.g.
163+
If you deploy your package to production (e.g. your package is a server) then
164+
any patched `devDependencies` will not be present when patch-package runs in
165+
production. It will happily ignore those patch files if the package to be
166+
patched is listed directly in the `devDependencies` of your package.json. If
167+
it's a transitive dependency patch-package can't detect that it is safe to
168+
ignore and will throw an error. To fix this, mark patches for transitive dev
169+
dependencies as dev-only by renaming from, e.g.
149170

150171
package-name+0.44.0.patch
151172

152173
to
153174

154175
package-name+0.44.0.dev.patch
155176

156-
This will allow those patch files to be safely ignored when `NODE_ENV=production`.
177+
This will allow those patch files to be safely ignored when
178+
`NODE_ENV=production`.
157179

158180
## Benefits of patching over forking
159181

160-
- Sometimes forks need extra build steps, e.g. with react-native for Android. Forget that noise.
161-
- Get told in big red letters when the dependency changed and you need to check that your fix is still valid.
182+
- Sometimes forks need extra build steps, e.g. with react-native for Android.
183+
Forget that noise.
184+
- Get told in big red letters when the dependency changed and you need to check
185+
that your fix is still valid.
162186
- Keep your patches colocated with the code that depends on them.
163-
- Patches can be reviewed as part of your normal review process, forks probably can't
187+
- Patches can be reviewed as part of your normal review process, forks probably
188+
can't
164189

165190
## When to fork instead
166191

@@ -170,18 +195,30 @@ This will allow those patch files to be safely ignored when `NODE_ENV=production
170195

171196
## Isn't this dangerous?
172197

173-
Nope. The technique is quite robust. Here are some things to keep in mind though:
198+
Nope. The technique is quite robust. Here are some things to keep in mind
199+
though:
174200

175-
- It's easy to forget to run `yarn` or `npm` when switching between branches that do and don't have patch files.
176-
- Long lived patches can be costly to maintain if they affect an area of code that is updated regularly and you want to update the package regularly too.
177-
- Big semantic changes can be hard to review. Keep them small and obvious or add plenty of comments.
178-
- Changes can also impact the behaviour of other untouched packages. It's normally obvious when this will happen, and often desired, but be careful nonetheless.
201+
- It's easy to forget to run `yarn` or `npm` when switching between branches
202+
that do and don't have patch files.
203+
- Long lived patches can be costly to maintain if they affect an area of code
204+
that is updated regularly and you want to update the package regularly too.
205+
- Big semantic changes can be hard to review. Keep them small and obvious or add
206+
plenty of comments.
207+
- Changes can also impact the behaviour of other untouched packages. It's
208+
normally obvious when this will happen, and often desired, but be careful
209+
nonetheless.
179210

180211
## Why use postinstall-postinstall with Yarn?
181212

182-
Most times when you do a `yarn`, `yarn add`, `yarn remove`, or `yarn install` (which is the same as just `yarn`) Yarn will completely replace the contents of your node_modules with freshly unpackaged modules. patch-package uses the `postinstall` hook to modify these fresh modules, so that they behave well according to your will.
213+
Most times when you do a `yarn`, `yarn add`, `yarn remove`, or `yarn install`
214+
(which is the same as just `yarn`) Yarn will completely replace the contents of
215+
your node_modules with freshly unpackaged modules. patch-package uses the
216+
`postinstall` hook to modify these fresh modules, so that they behave well
217+
according to your will.
183218

184-
Yarn only runs the `postinstall` hook after `yarn` and `yarn add`, but not after `yarn remove`. The `postinstall-postinstall` package is used to make sure your `postinstall` hook gets executed even after a `yarn remove`.
219+
Yarn only runs the `postinstall` hook after `yarn` and `yarn add`, but not after
220+
`yarn remove`. The `postinstall-postinstall` package is used to make sure your
221+
`postinstall` hook gets executed even after a `yarn remove`.
185222

186223
## License
187224

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"jest": "^24.5.0",
6060
"lint-staged": "^8.1.5",
6161
"np": "^4.0.2",
62-
"prettier": "^1.16.4",
62+
"prettier": "^1.18.2",
6363
"randomstring": "^1.1.5",
6464
"ts-jest": "^24.0.0",
6565
"ts-node": "8.0.3",

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -3772,10 +3772,10 @@ prepend-http@^2.0.0:
37723772
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
37733773
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=
37743774

3775-
prettier@^1.16.4:
3776-
version "1.16.4"
3777-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717"
3778-
integrity sha512-ZzWuos7TI5CKUeQAtFd6Zhm2s6EpAD/ZLApIhsF9pRvRtM1RFo61dM/4MSRUA0SuLugA/zgrZD8m0BaY46Og7g==
3775+
prettier@^1.18.2:
3776+
version "1.18.2"
3777+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
3778+
integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==
37793779

37803780
pretty-format@^24.5.0:
37813781
version "24.5.0"

0 commit comments

Comments
 (0)