Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(outdated): error when there are no config files #27306

Merged
10 changes: 10 additions & 0 deletions cli/tools/registry/pm/outdated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::collections::HashSet;
use std::sync::Arc;

use deno_core::anyhow::bail;
use deno_core::error::AnyError;
use deno_semver::package::PackageNv;
use deno_semver::package::PackageReq;
Expand Down Expand Up @@ -197,6 +198,15 @@ pub async fn outdated(
let jsr_fetch_resolver =
Arc::new(JsrFetchResolver::new(file_fetcher.clone()));

if !cli_options.start_dir.has_deno_json()
&& !cli_options.start_dir.has_pkg_json()
{
bail!(
"No deno.json or package.json in \"{}\".",
cli_options.initial_cwd().display(),
);
}
dsherret marked this conversation as resolved.
Show resolved Hide resolved

let args = dep_manager_args(
&factory,
cli_options,
Expand Down
10 changes: 10 additions & 0 deletions tests/specs/update/deno_json/__test__.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"args": "outdated",
"output": "outdated.out"
},
{
// Filtering that matches nothing, should exit cleanly
"args": "outdated foobar",
"output": ""
},
{
// Respect `--quiet flag and don't print hint how to update
"args": "outdated --quiet",
Expand All @@ -43,6 +48,11 @@
{
"args": "outdated --compatible",
"output": "outdated_compatible.out"
},
{
// Filtering that matches nothing, should exit cleanly
"args": "outdated --compatible foobar",
"output": ""
}
]
},
Expand Down
10 changes: 10 additions & 0 deletions tests/specs/update/mixed_workspace/__test__.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
{
"args": "outdated",
"output": "print_outdated/root.out"
},
{
// Filtering that matches nothing, should exit cleanly
"args": "outdated foobar",
"output": ""
}
]
},
Expand All @@ -38,6 +43,11 @@
{
"args": "outdated --recursive",
"output": "print_outdated/recursive.out"
},
{
// Filtering that matches nothing, should exit cleanly
"args": "outdated foobar",
"output": ""
}
]
},
Expand Down
6 changes: 6 additions & 0 deletions tests/specs/update/no_config_file/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tempDir": true,
"args": "outdated",
"exitCode": 1,
"output": "error: No deno.json or package.json in \"[WILDLINE]\".\n"
}
10 changes: 10 additions & 0 deletions tests/specs/update/package_json/__test__.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
{
"args": "outdated",
"output": "outdated.out"
},
{
// Filtering that matches nothing, should exit cleanly
"args": "outdated foobar",
"output": ""
}
]
},
Expand All @@ -37,6 +42,11 @@
{
"args": "outdated --compatible",
"output": "outdated_compatible.out"
},
{
// Filtering that matches nothing, should exit cleanly
"args": "outdated --compatible foobar",
"output": ""
}
]
},
Expand Down
Loading