diff --git a/package.json b/package.json index 8740e10..91ecbef 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "node": ">=24" }, "scripts": { - "build": "pika build", + "build": "pika build && node scripts/fix-package-json.js", "prerelease": "pnpm install --force && pnpm run lint && pnpm run tsc && pnpm run build", "release": "npm publish ./pkg", "lint": "js-tools lint", diff --git a/scripts/fix-package-json.js b/scripts/fix-package-json.js new file mode 100644 index 0000000..c11c7d2 --- /dev/null +++ b/scripts/fix-package-json.js @@ -0,0 +1,21 @@ +// Script to fix the package.json files map. This is needed because npm changed the file matching behavior in npm@9. +// And pika does not support the new behavior. +// @see https://github.com/octokit/plugin-retry.js/issues/405 + +'use strict'; + +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');