mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
[bun run] Fix bug with yarn getting replaced for - commands
This commit is contained in:
@@ -94,6 +94,14 @@ pub const RunCommand = struct {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strings.startsWith(yarn_cmd, "-")) {
|
||||
// Skip the rest of the command
|
||||
entry_i += "yarn ".len + yarn_cmd.len;
|
||||
try copy_script.appendSlice("yarn ");
|
||||
try copy_script.appendSlice(yarn_cmd);
|
||||
continue;
|
||||
}
|
||||
|
||||
// implicit yarn commands
|
||||
if (std.mem.indexOfScalar(u64, yarn_commands, std.hash.Wyhash.hash(0, yarn_cmd)) == null) {
|
||||
try copy_script.appendSlice("bun run");
|
||||
@@ -887,6 +895,18 @@ test "replacePackageManagerRun" {
|
||||
try std.testing.expectEqualStrings(copy_script.items, "yarn install foo");
|
||||
}
|
||||
|
||||
{
|
||||
copy_script.clearRetainingCapacity();
|
||||
try RunCommand.replacePackageManagerRun(©_script, "yarn --prod");
|
||||
try std.testing.expectEqualStrings(copy_script.items, "yarn --prod");
|
||||
}
|
||||
|
||||
{
|
||||
copy_script.clearRetainingCapacity();
|
||||
try RunCommand.replacePackageManagerRun(©_script, "yarn -prod");
|
||||
try std.testing.expectEqualStrings(copy_script.items, "yarn -prod");
|
||||
}
|
||||
|
||||
{
|
||||
copy_script.clearRetainingCapacity();
|
||||
try RunCommand.replacePackageManagerRun(©_script, "yarn");
|
||||
|
||||
Reference in New Issue
Block a user