summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/args/flags.rs6
-rw-r--r--cli/tools/info.rs10
-rw-r--r--tests/integration/info_tests.rs22
3 files changed, 33 insertions, 5 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 59d747167..3b6810a95 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -1784,8 +1784,9 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
.arg(no_config_arg())
.arg(no_remote_arg())
.arg(no_npm_arg())
- .arg(no_lock_arg())
.arg(lock_arg())
+ .arg(lock_write_arg())
+ .arg(no_lock_arg())
.arg(config_arg())
.arg(import_map_arg())
.arg(node_modules_dir_arg())
@@ -3506,8 +3507,7 @@ fn info_parse(flags: &mut Flags, matches: &mut ArgMatches) {
location_arg_parse(flags, matches);
ca_file_arg_parse(flags, matches);
node_modules_and_vendor_dir_arg_parse(flags, matches);
- lock_arg_parse(flags, matches);
- no_lock_arg_parse(flags, matches);
+ lock_args_parse(flags, matches);
no_remote_arg_parse(flags, matches);
no_npm_arg_parse(flags, matches);
let json = matches.get_flag("json");
diff --git a/cli/tools/info.rs b/cli/tools/info.rs
index dd820f24f..0ad7d8920 100644
--- a/cli/tools/info.rs
+++ b/cli/tools/info.rs
@@ -7,6 +7,7 @@ use std::fmt::Write;
use deno_ast::ModuleSpecifier;
use deno_core::anyhow::bail;
+use deno_core::anyhow::Context;
use deno_core::error::AnyError;
use deno_core::resolve_url_or_path;
use deno_core::serde_json;
@@ -66,8 +67,13 @@ pub async fn info(flags: Flags, info_flags: InfoFlags) -> Result<(), AnyError> {
.create_graph_with_loader(GraphKind::All, vec![specifier], &mut loader)
.await?;
- if let Some(lockfile) = maybe_lockfile {
- graph_lock_or_exit(&graph, &mut lockfile.lock());
+ // If there is a lockfile...
+ if let Some(lockfile) = &maybe_lockfile {
+ let mut lockfile = lockfile.lock();
+ // validate the integrity of all the modules
+ graph_lock_or_exit(&graph, &mut lockfile);
+ // update it with anything new
+ lockfile.write().context("Failed writing lockfile.")?;
}
if info_flags.json {
diff --git a/tests/integration/info_tests.rs b/tests/integration/info_tests.rs
index c3de0e470..8fae81a61 100644
--- a/tests/integration/info_tests.rs
+++ b/tests/integration/info_tests.rs
@@ -30,6 +30,28 @@ fn info_with_compiled_source() {
assert_eq!(output.stderr(), "");
}
+#[test]
+fn info_lock_write() {
+ let context = TestContextBuilder::new().use_http_server().build();
+
+ context.temp_dir().write("deno.json", "{}");
+
+ let module_path = "http://127.0.0.1:4545/run/048_media_types_jsx.ts";
+
+ let output = context
+ .new_command()
+ .current_dir(context.temp_dir().path())
+ .args_vec(["info", module_path])
+ .run();
+ output.assert_exit_code(0);
+ output.skip_output_check();
+
+ assert!(
+ context.temp_dir().path().join("deno.lock").exists(),
+ "missing deno.lock"
+ );
+}
+
itest!(multiple_imports {
args: "info http://127.0.0.1:4545/run/019_media_types.ts",
output: "info/multiple_imports.out",