Skip to content

Commit 7e56c16

Browse files
authored
fix(build): add script to fix package.json before publishing (#494)
1 parent f8c5c0d commit 7e56c16

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
cache: npm
1616
- run: npm ci
1717
- run: npm run build
18+
# https://github.com/octokit/action.js/pull/494
19+
- name: "Fix pkg.files file pattern"
20+
run: node scripts/fix-package-json.js
1821
- run: npx semantic-release
1922
env:
2023
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/fix-package-json.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Script to fix the package.json files map. This is needed because npm changed the file matching behavior in npm@9
2+
// https://github.com/octokit/action.js/pull/494
3+
const fs = require("fs");
4+
const path = require("path");
5+
const { EOL } = require("os");
6+
7+
const pkgPath = path.join(__dirname, "../pkg/package.json");
8+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
9+
10+
pkg.files = pkg.files.map((file) => {
11+
if (file.endsWith("/")) {
12+
return file + "**";
13+
}
14+
return file;
15+
});
16+
17+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + EOL, "utf8");

0 commit comments

Comments
 (0)