Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: add global arg to pm-install generator #53

Open
wants to merge 4 commits 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
4 changes: 4 additions & 0 deletions docs/2.generators/pm-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ The package name (by default tries to read from the `name` field in `package.jso
Install as a dev dependency (defaults to `false`).
::

::field{name="global" type="boolean"}
Install globally (useful for CLIs) (defaults to `false`).
::

::field{name="separate" type="boolean"}
Separate code blocks for each package manager (defaults to `false`).
::
Expand Down
2 changes: 1 addition & 1 deletion src/generators/pm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const pmInstall = defineGenerator({

const contents = commands.map(
([cmd, install]) =>
`# ${cmd.includes("nypm") ? "✨ Auto-detect" : cmd}\n${cmd} ${install}${args.dev ? " -D" : ""} ${name}${versionSuffix}`,
`# ${cmd.includes("nypm") ? "✨ Auto-detect" : cmd}\n${cmd} ${install} ${args.global ? "-g" : (args.dev ? "-D" : "")} ${name}${versionSuffix}`,
);

if ((args.separate ?? false) === false) {
Expand Down