aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Justin Whear <justin.whear@gmail.com> 2023-02-28 16:39:06 -0800
committerGravatar GitHub <noreply@github.com> 2023-02-28 16:39:06 -0800
commitec20fae57f96a835562b154730957ecc4015ba31 (patch)
treeb7d49eb2b2a1fec8372f784bfd1243870686eb56
parentfd19d01583aace00925dbe80f1cad4696efeb569 (diff)
downloadbun-ec20fae57f96a835562b154730957ecc4015ba31.tar.gz
bun-ec20fae57f96a835562b154730957ecc4015ba31.tar.zst
bun-ec20fae57f96a835562b154730957ecc4015ba31.zip
Add `-D`, `--dev` flags for bun install (#2240)
* remove vendored clap * Update to latest zig-clap Major changes: * Instead of vendoring zig-clap and adding changes, this uses Hejsil/zig-clap directly as a submodule * `cli.zig` and related files have been updated to use new API (no more `flag()` or `option()`) * A workaround for the Run and Auto commands has been implemented that allows us to use the official upstream Minor change: * `-i` now has the long option `--install-fallback`; I didn't spend much time thinking about this name, so suggestions weclome. * add --development and --optional to bun install * Add support for `-D`, `--dev` in bun install, fix `--save`
-rw-r--r--src/install/install.zig18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/install/install.zig b/src/install/install.zig
index 5399a6fd3..9265e6c29 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -5300,15 +5300,15 @@ pub const PackageManager = struct {
// clap.parseParam("--no-dedupe Disable automatic downgrading of dependencies that would otherwise cause unnecessary duplicate package versions ($BUN_CONFIG_NO_DEDUPLICATE)") catch unreachable,
+ // Note that zig-clap currently doesn't support multiple short or long names,
+ // so for npm/yarn compatibility we'll specify both --development and --dev
pub const install_params = install_params_ ++ clap.parseParamsComptime(
- \\<STR> ...
- );
-
- pub const add_params = install_params_ ++ clap.parseParamsComptime(
\\-d, --development Add dependency to "devDependencies"
- \\--optional Add dependency to "optionalDependencies"
+ \\-D, --dev Add dependency to "devDependencies" (npm/yarn compat)
+ \\-O, --optional Add dependency to "optionalDependencies"
\\<STR> ... "name" or "name@version" of packages to install
);
+ pub const add_params = install_params;
pub const remove_params = install_params_ ++ clap.parseParamsComptime(
\\<STR> ... "name" of packages to remove from package.json
@@ -5414,7 +5414,7 @@ pub const PackageManager = struct {
cli.ignore_scripts = res.args.@"ignore-scripts";
cli.no_summary = res.args.@"no-summary";
- if (comptime @hasDecl(@TypeOf(res.args), "save")) {
+ if (comptime @hasField(@TypeOf(res.args), "save")) {
cli.no_save = true;
if (res.args.save) {
@@ -5430,10 +5430,10 @@ pub const PackageManager = struct {
cli.link_native_bins = res.args.@"link-native-bins";
- if (comptime params.len == add_params.len) {
- cli.development = res.args.development;
+ if (@hasField(@TypeOf(res.args), "development"))
+ cli.development = res.args.development or res.args.dev;
+ if (@hasField(@TypeOf(res.args), "optional"))
cli.optional = res.args.optional;
- }
// for (res.args.omit) |omit| {
// if (strings.eqlComptime(omit, "dev")) {