This commit is contained in:
RiskyMH
2025-06-13 18:40:39 +10:00
parent 471b423ec8
commit 4e8252da9d
2 changed files with 7 additions and 5 deletions

View File

@@ -350,14 +350,16 @@ pub const UpgradeCommand = struct {
if (args.len > 2) {
var upgrade_index: ?usize = null;
for (args[1..], 1..) |arg, i| {
if (upgrade_index == null and strings.eqlComptime(arg, "upgrade")) {
upgrade_index = i + 1;
continue;
if (upgrade_index) |_| {
if (strings.eqlComptime(arg, "upgrade")) {
upgrade_index = i + 1;
continue;
}
}
// if this is before the "upgrade", just judge that it's a flag (because BUN_OPTIONS are passed here)
// otherwise, needs to be one of the specific flags
if (upgrade_index == null) {
if (upgrade_index) |_| {
if (strings.startsWith(arg, "--")) continue;
} else {
if (strings.eqlComptime(arg, "--canary") or

View File

@@ -43,7 +43,7 @@ const invalid_tests = [
[["upgrade", "--latest"], "bun update --latest"],
];
for (const [args, expected] of invalid_tests) {
it("two invalid arguments, should display error message and suggest command", async () => {
it(`"${args.join(" ")}": should display error message and suggest command`, async () => {
const { stderr } = spawn({
cmd: [execPath, ...args],
cwd,