Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: remove cross-env if pnpm is used #305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
shell-emulator=true
legacy-peer-deps=true
15 changes: 13 additions & 2 deletions remix.init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, "\\$&");
Expand Down Expand Up @@ -88,15 +96,18 @@ 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:
packageManager.name === "bun"
? prismaSeed.replace("tsx", "bun")
: prismaSeed,
},
scripts,
scripts:
packageManager.name === "pnpm" ? cleanupScriptsForPnpm(scripts) : scripts,
});
};

Expand Down