From 75496593c51cd521f878db0ef1f554f7ca72e55c Mon Sep 17 00:00:00 2001 From: Oscar Dominguez Date: Fri, 3 Mar 2023 23:59:16 +0100 Subject: [PATCH] fix(ci): add script to fix package json from build step (#410) * fix(ci): add hotfix in built package.json to use proper file patterns in "files" You can read more here: https://github.com/octokit/plugin-retry.js/issues/405 * ci(release): run 'scripts/fix-package-json.js' before release --- .github/workflows/release.yml | 2 ++ scripts/fix-package-json.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 scripts/fix-package-json.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0022b46..84a301b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,8 @@ jobs: cache: npm - run: npm ci - run: npm run build + - 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..d10147c --- /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");