diff options
author | 2022-02-12 16:05:57 -0800 | |
---|---|---|
committer | 2022-02-12 16:05:57 -0800 | |
commit | f33d23c0b4c74fe2fe89d9268f7c66b5b25c1bab (patch) | |
tree | f976add25d6ae8f5515ee96f45dfef4d51fed6b1 | |
parent | b9567eb193a90aebb3e271de56dd3edf1d2905c1 (diff) | |
download | bun-f33d23c0b4c74fe2fe89d9268f7c66b5b25c1bab.tar.gz bun-f33d23c0b4c74fe2fe89d9268f7c66b5b25c1bab.tar.zst bun-f33d23c0b4c74fe2fe89d9268f7c66b5b25c1bab.zip |
[bun install] When both `directories` and `bin` is specified, prefer `bin`
This is for performance.
-rw-r--r-- | src/install/npm.zig | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/install/npm.zig b/src/install/npm.zig index dab1d2606..55ce92171 100644 --- a/src/install/npm.zig +++ b/src/install/npm.zig @@ -1070,7 +1070,7 @@ pub const PackageManifest = struct { switch (bin.expr.data) { .e_object => |obj| { switch (obj.properties.len) { - 0 => break :bin, + 0 => {}, 1 => { const bin_name = obj.properties.ptr[0].key.?.asString(allocator) orelse break :bin; const value = obj.properties.ptr[0].value.?.asString(allocator) orelse break :bin; @@ -1118,6 +1118,8 @@ pub const PackageManifest = struct { }; }, } + + break :bin; }, .e_string => |str| { if (str.utf8.len > 0) { @@ -1135,6 +1137,13 @@ pub const PackageManifest = struct { } if (prop.value.?.asProperty("directories")) |dirs| { + // https://docs.npmjs.com/cli/v8/configuring-npm/package-json#directoriesbin + // Because of the way the bin directive works, + // specifying both a bin path and setting + // directories.bin is an error. If you want to + // specify individual files, use bin, and for all + // the files in an existing bin directory, use + // directories.bin. if (dirs.expr.asProperty("bin")) |bin_prop| { if (bin_prop.expr.asString(allocator)) |str_| { if (str_.len > 0) { |