Skip to content

Commit a82bbed

Browse files
authored
Merge branch 'master' into feature/ignore-errors-option
2 parents eb62cdc + 50f73bd commit a82bbed

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 6.2.2
4+
5+
- Take config from .yarnrc when making patches (contribution from @NMinhNguyen in #222)
6+
37
## 6.2.1
48

59
- Avoid infinite loop when invoked without package.json

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "patch-package",
3-
"version": "6.2.1",
3+
"version": "6.2.2",
44
"description": "Fix broken node modules with no fuss",
55
"main": "dist/index.js",
66
"repository": "https://github.com/ds300/patch-package",

src/makePatch.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ export function makePatch({
102102
"package.json",
103103
)).version as string
104104

105-
// copy .npmrc in case if packages are hosted in private registry
106-
const npmrcPath = join(appPath, ".npmrc")
107-
if (existsSync(npmrcPath)) {
108-
copySync(npmrcPath, join(tmpRepo.name, ".npmrc"))
109-
}
105+
// copy .npmrc/.yarnrc in case packages are hosted in private registry
106+
[".npmrc", ".yarnrc"].forEach(rcFile => {
107+
const rcPath = join(appPath, rcFile)
108+
if (existsSync(rcPath)) {
109+
copySync(rcPath, join(tmpRepo.name, rcFile))
110+
}
111+
})
110112

111113
if (packageManager === "yarn") {
112114
console.info(
@@ -155,13 +157,13 @@ export function makePatch({
155157
const git = (...args: string[]) =>
156158
spawnSafeSync("git", args, {
157159
cwd: tmpRepo.name,
158-
env: { HOME: tmpRepo.name },
160+
env: { ...process.env, HOME: tmpRepo.name },
159161
})
160162

161163
// remove nested node_modules just to be safe
162164
rimraf(join(tmpRepoPackagePath, "node_modules"))
163165
// remove .git just to be safe
164-
rimraf(join(tmpRepoPackagePath, "node_modules"))
166+
rimraf(join(tmpRepoPackagePath, ".git"))
165167

166168
// commit the package
167169
console.info(chalk.grey("•"), "Diffing your files with clean files")

0 commit comments

Comments
 (0)