From 78081cbb40b3149be3fcd7f050ec365c499421d0 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Fri, 4 Aug 2023 20:41:16 -0700 Subject: [PATCH] Support --dev/-D and support more flags on bun install (#3989) --- completions/bun.zsh | 6 +++--- docs/cli/install.md | 2 +- docs/guides/install/add-dev.md | 2 +- docs/install/index.md | 2 +- src/install/install.zig | 11 ++++++++--- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/completions/bun.zsh b/completions/bun.zsh index a8f66b4fa3..59df1db47b 100644 --- a/completions/bun.zsh +++ b/completions/bun.zsh @@ -49,7 +49,7 @@ _bun() { '--production[Don'"'"'t install devDependencies]' \ '--frozen-lockfile[Disallow changes to lockfile]' \ '--optional[Add dependency to optionalDependencies]' \ - '--development[Add dependency to devDependencies]' \ + '--dev[Add dependency to devDependencies]' \ '-d[Add dependency to devDependencies]' \ '-p[Don'"'"'t install devDependencies]' \ '--no-save[]' \ @@ -91,7 +91,7 @@ _bun() { '--production[Don'"'"'t install devDependencies]' \ '--frozen-lockfile[Disallow changes to lockfile]' \ '--optional[Add dependency to optionalDependencies]' \ - '--development[Add dependency to devDependencies]' \ + '--dev[Add dependency to devDependencies]' \ '-d[Add dependency to devDependencies]' \ '-p[Don'"'"'t install devDependencies]' \ '--no-save[]' \ @@ -127,7 +127,7 @@ _bun() { '--production[Don'"'"'t install devDependencies]' \ '--frozen-lockfile[Disallow changes to lockfile]' \ '--optional[Add dependency to optionalDependencies]' \ - '--development[Add dependency to devDependencies]' \ + '--dev[Add dependency to devDependencies]' \ '-d[Add dependency to devDependencies]' \ '-p[Don'"'"'t install devDependencies]' \ '--no-save[]' \ diff --git a/docs/cli/install.md b/docs/cli/install.md index 02f095d618..9b323a8aa8 100644 --- a/docs/cli/install.md +++ b/docs/cli/install.md @@ -114,7 +114,7 @@ $ bun add zod@latest To add a package as a dev dependency (`"devDependencies"`): ```bash -$ bun add --development @types/react +$ bun add --dev @types/react $ bun add -d @types/react ``` diff --git a/docs/guides/install/add-dev.md b/docs/guides/install/add-dev.md index 833f8cfa28..3f7b74f9c7 100644 --- a/docs/guides/install/add-dev.md +++ b/docs/guides/install/add-dev.md @@ -5,7 +5,7 @@ name: Add a development dependency To add an npm package as a development dependency, use `bun add --development`. ```sh -$ bun add zod --development +$ bun add zod --dev $ bun add zod -d # shorthand ``` diff --git a/docs/install/index.md b/docs/install/index.md index 162a4abacf..540ade9f03 100644 --- a/docs/install/index.md +++ b/docs/install/index.md @@ -114,7 +114,7 @@ $ bun add zod@latest To add a package as a dev dependency (`"devDependencies"`): ```bash -$ bun add --development @types/react +$ bun add --dev @types/react $ bun add -d @types/react ``` diff --git a/src/install/install.zig b/src/install/install.zig index 2c78c81a2d..13338c53be 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -5763,6 +5763,10 @@ pub const PackageManager = struct { }; const install_params = install_params_ ++ [_]ParamType{ + clap.parseParam("-d, --dev Add dependency to \"devDependencies\"") catch unreachable, + clap.parseParam("-D, --development") catch unreachable, + clap.parseParam("--optional Add dependency to \"optionalDependencies\"") catch unreachable, + clap.parseParam("--exact Add the exact version instead of the ^range") catch unreachable, clap.parseParam(" ... ") catch unreachable, }; @@ -5771,7 +5775,8 @@ pub const PackageManager = struct { }; const add_params = install_params_ ++ [_]ParamType{ - clap.parseParam("-d, --development Add dependency to \"devDependencies\"") catch unreachable, + clap.parseParam("-d, --dev Add dependency to \"devDependencies\"") catch unreachable, + clap.parseParam("-D, --development") catch unreachable, clap.parseParam("--optional Add dependency to \"optionalDependencies\"") catch unreachable, clap.parseParam("--exact Add the exact version instead of the ^range") catch unreachable, clap.parseParam(" ... \"name\" or \"name@version\" of packages to install") catch unreachable, @@ -5901,8 +5906,8 @@ pub const PackageManager = struct { cli.link_native_bins = args.options("--link-native-bins"); - if (comptime subcommand == .add) { - cli.development = args.flag("--development"); + if (comptime subcommand == .add or subcommand == .install) { + cli.development = args.flag("--development") or args.flag("--dev"); cli.optional = args.flag("--optional"); cli.exact = args.flag("--exact"); }