From 3479aa55670c941255e8a644ad28582d0c935fca Mon Sep 17 00:00:00 2001 From: Joram van den Boezem Date: Thu, 24 Nov 2022 11:28:59 +0000 Subject: [PATCH] fix: patch semantic-release/npm --- package.json | 3 ++- scripts/patch-semantic-commit.js | 19 +++++++++++++++++++ scripts/postinstall.js | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 scripts/patch-semantic-commit.js create mode 100644 scripts/postinstall.js diff --git a/package.json b/package.json index 893b5631..b2803976 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "repository": "https://github.com/hongaar/moker", "author": "joram@vandenboezem.nl", "license": "MIT", + "type": "module", "workspaces": [ "packages/*" ], @@ -22,7 +23,7 @@ "test": "yarn workspaces foreach --topological --verbose run test", "watch:build": "yarn workspaces foreach --parallel --interlaced run watch:build", "watch:test": "yarn workspaces foreach --parallel --interlaced run watch:test", - "postinstall": "husky install", + "postinstall": "husky install && node scripts/postinstall.js", "format": "prettier --write --ignore-unknown .", "doctoc": "doctoc README.md", "leasot": "leasot --exit-nicely --reporter markdown --ignore \"**/node_modules\" \"**/*.ts\" > TODO.md", diff --git a/scripts/patch-semantic-commit.js b/scripts/patch-semantic-commit.js new file mode 100644 index 00000000..85366889 --- /dev/null +++ b/scripts/patch-semantic-commit.js @@ -0,0 +1,19 @@ +import fs from "node:fs"; +import { join } from "node:path"; + +const path = join( + "node_modules", + "@semantic-release", + "npm", + "lib", + "verify-auth.js" +); + +export function patchSemanticCommit() { + const contents = fs.readFileSync(path, "utf8"); + const patched = contents.replace( + `execa('npm', ['whoami', '--userconfig', npmrc, '--registry', registry]`, + `execa('npm', ['whoami', '--userconfig', npmrc, '--registry', registry, '--no-workspaces']` + ); + fs.writeFileSync(path, patched, "utf8"); +} diff --git a/scripts/postinstall.js b/scripts/postinstall.js new file mode 100644 index 00000000..e3c01e99 --- /dev/null +++ b/scripts/postinstall.js @@ -0,0 +1,3 @@ +import { patchSemanticCommit } from "./patch-semantic-commit.js"; + +patchSemanticCommit();