From 8bf2c5ff5022fc4bc1f27f86d79e188d917d37ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Fri, 4 Oct 2024 02:52:05 +0200 Subject: [PATCH] feat: remove `cross-env` if pnpm is used --- .npmrc | 1 + remix.init/index.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.npmrc b/.npmrc index 521a9f7c..25cb47ea 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ +shell-emulator=true legacy-peer-deps=true diff --git a/remix.init/index.js b/remix.init/index.js index 132c6a63..b6eba667 100644 --- a/remix.init/index.js +++ b/remix.init/index.js @@ -17,6 +17,14 @@ const cleanupCypressFiles = ({ fileEntries, packageManager }) => return [fs.writeFile(filePath, newContent)]; }); +const cleanupScriptsForPnpm = (scripts) => + Object.fromEntries( + Object.entries(scripts).map(([key, value]) => [ + key, + value.replace("cross-env ", ""), + ]), + ); + const escapeRegExp = (string) => // $& means the whole matched string string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); @@ -88,7 +96,9 @@ const updatePackageJson = ({ APP_NAME, packageJson, packageManager }) => { devDependencies: packageManager.name === "bun" ? removeUnusedDependencies(devDependencies, ["tsx"]) - : devDependencies, + : packageManager.name === "pnpm" + ? removeUnusedDependencies(devDependencies, ["cross-env"]) + : devDependencies, prisma: { ...prisma, seed: @@ -96,7 +106,8 @@ const updatePackageJson = ({ APP_NAME, packageJson, packageManager }) => { ? prismaSeed.replace("tsx", "bun") : prismaSeed, }, - scripts, + scripts: + packageManager.name === "pnpm" ? cleanupScriptsForPnpm(scripts) : scripts, }); };