Skip to content

Commit

Permalink
feat: Deprecate --lock-write flag (#24436)
Browse files Browse the repository at this point in the history
This commit deprecates `--lock-write` flag by removing it from
the help output and printing a warning message when it's used.

Users should use `--frozen=false` instead which was added
in #24355.

Towards #24167.
  • Loading branch information
bartlomieju authored Jul 5, 2024
1 parent d91215d commit 0bbfd6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ pub struct Flags {
pub inspect_wait: Option<SocketAddr>,
pub inspect: Option<SocketAddr>,
pub location: Option<Url>,
// TODO(bartlomieju): deprecated, to be removed in Deno 2.
pub lock_write: bool,
pub lock: Option<String>,
pub log_level: Option<Level>,
Expand Down Expand Up @@ -3623,12 +3624,14 @@ If value is not provided, defaults to \"deno.lock\" in the current working direc
.value_hint(ValueHint::FilePath)
}

// TODO(bartlomieju): deprecated, to be removed in Deno 2.
fn lock_write_arg() -> Arg {
Arg::new("lock-write")
.action(ArgAction::SetTrue)
.long("lock-write")
.help("Force overwriting the lock file.")
.conflicts_with("no-lock")
.hide(true)
}

fn no_lock_arg() -> Arg {
Expand Down Expand Up @@ -4747,6 +4750,7 @@ fn check_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) {
fn lock_args_parse(flags: &mut Flags, matches: &mut ArgMatches) {
lock_arg_parse(flags, matches);
no_lock_arg_parse(flags, matches);
// TODO(bartlomieju): deprecated, to be removed in Deno 2.
if matches.get_flag("lock-write") {
flags.lock_write = true;
}
Expand Down
4 changes: 4 additions & 0 deletions cli/args/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ impl CliLockfile {
};

let lockfile = if flags.lock_write {
log::warn!(
"{} \"--lock-write\" flag is deprecated and will be removed in Deno 2.",
crate::colors::yellow("Warning")
);
CliLockfile::new(
Lockfile::new_empty(filename, true),
flags.frozen_lockfile,
Expand Down
1 change: 1 addition & 0 deletions tests/testdata/lockfile/no_dts/main.cache.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Warning "--lock-write" flag is deprecated and will be removed in Deno 2.
Download http://localhost:4545/lockfile/no_dts/mod.js
Download http://localhost:4545/lockfile/no_dts/mod.d.ts

0 comments on commit 0bbfd6f

Please sign in to comment.