From f961a6dfd7e919581fa9b3b88351f0a37f1f61a8 Mon Sep 17 00:00:00 2001 From: wolfy1339 <4595477+wolfy1339@users.noreply.github.com> Date: Tue, 16 May 2023 16:53:59 -0400 Subject: [PATCH] fix(build): add script to fix `package.json` before publishing (#127) --- .github/workflows/release.yml | 3 +++ scripts/fix-package-json.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 scripts/fix-package-json.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c06da8d..bd53d4b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,9 @@ jobs: cache: npm - run: npm ci - run: npm run build + # https://github.com/gr2m/octokit-plugin-create-pull-request/pull/127/ + - name: "Fix pkg.files file pattern" + run: node scripts/fix-package-json.js - run: npx semantic-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/fix-package-json.js b/scripts/fix-package-json.js new file mode 100644 index 0000000..76ab50e --- /dev/null +++ b/scripts/fix-package-json.js @@ -0,0 +1,15 @@ +const fs = require("fs"); +const path = require("path"); +const { EOL } = require("os"); + +const pkgPath = path.join(__dirname, "../pkg/package.json"); +const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8")); + +pkg.files = pkg.files.map((file) => { + if (file.endsWith("/")) { + return file + "**"; + } + return file; +}); + +fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + EOL, "utf8");