Skip to content

Commit 5c173d2

Browse files
authored
chore: Create apply patches script (#36793)
1 parent 1fb1838 commit 5c173d2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scripts/apply-patches.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Apply patches in order. Extracted from logic in release-next-major.js.
3+
*/
4+
5+
const path = require(`path`)
6+
const { execSync } = require(`child_process`)
7+
const glob = require(`glob`)
8+
9+
const gatsbyPKG = require(`../packages/gatsby/package.json`)
10+
const nextMajor = String(Number(gatsbyPKG.version.match(/[^.]+/)[0]) + 1)
11+
12+
const patchFiles = glob.sync(`patches/v${nextMajor}/*.patch`, {
13+
cwd: path.join(__dirname, `..`),
14+
})
15+
16+
for (const patchFile of patchFiles) {
17+
console.log(`Applying patch ${patchFile}`)
18+
try {
19+
execSync(`git apply ${patchFile}`, {
20+
cwd: path.join(__dirname, `..`),
21+
stdio: `pipe`,
22+
})
23+
} catch (err) {
24+
console.log(err.stderr.toString())
25+
// eslint-disable-next-line
26+
throw ``
27+
}
28+
}

0 commit comments

Comments
 (0)