@@ -498,6 +498,7 @@ pub struct Flags {
498
498
pub argv : Vec < String > ,
499
499
pub subcommand : DenoSubcommand ,
500
500
501
+ pub frozen_lockfile : bool ,
501
502
pub ca_stores : Option < Vec < String > > ,
502
503
pub ca_data : Option < CaData > ,
503
504
pub cache_blocklist : Vec < String > ,
@@ -1487,12 +1488,15 @@ Future runs of this module will trigger no downloads or compilation unless
1487
1488
--reload is specified." ,
1488
1489
)
1489
1490
. defer ( |cmd| {
1490
- compile_args ( cmd) . arg ( check_arg ( false ) ) . arg (
1491
- Arg :: new ( "file" )
1492
- . num_args ( 1 ..)
1493
- . required ( true )
1494
- . value_hint ( ValueHint :: FilePath ) ,
1495
- )
1491
+ compile_args ( cmd)
1492
+ . arg ( check_arg ( false ) )
1493
+ . arg (
1494
+ Arg :: new ( "file" )
1495
+ . num_args ( 1 ..)
1496
+ . required ( true )
1497
+ . value_hint ( ValueHint :: FilePath ) ,
1498
+ )
1499
+ . arg ( frozen_lockfile_arg ( ) )
1496
1500
} )
1497
1501
}
1498
1502
@@ -3271,6 +3275,7 @@ fn runtime_args(
3271
3275
app
3272
3276
} ;
3273
3277
app
3278
+ . arg ( frozen_lockfile_arg ( ) )
3274
3279
. arg ( cached_only_arg ( ) )
3275
3280
. arg ( location_arg ( ) )
3276
3281
. arg ( v8_flags_arg ( ) )
@@ -3384,6 +3389,17 @@ fn cached_only_arg() -> Arg {
3384
3389
. help ( "Require that remote dependencies are already cached" )
3385
3390
}
3386
3391
3392
+ fn frozen_lockfile_arg ( ) -> Arg {
3393
+ Arg :: new ( "frozen" )
3394
+ . long ( "frozen" )
3395
+ . alias ( "frozen-lockfile" )
3396
+ . value_parser ( value_parser ! ( bool ) )
3397
+ . num_args ( 0 ..=1 )
3398
+ . require_equals ( true )
3399
+ . default_missing_value ( "true" )
3400
+ . help ( "Error out if lockfile is out of date" )
3401
+ }
3402
+
3387
3403
/// Used for subcommands that operate on executable scripts only.
3388
3404
/// `deno fmt` has its own `--ext` arg because its possible values differ.
3389
3405
/// If --ext is not provided and the script doesn't have a file extension,
@@ -3774,6 +3790,7 @@ fn bundle_parse(flags: &mut Flags, matches: &mut ArgMatches) {
3774
3790
3775
3791
fn cache_parse ( flags : & mut Flags , matches : & mut ArgMatches ) {
3776
3792
compile_args_parse ( flags, matches) ;
3793
+ frozen_lockfile_arg_parse ( flags, matches) ;
3777
3794
let files = matches. remove_many :: < String > ( "file" ) . unwrap ( ) . collect ( ) ;
3778
3795
flags. subcommand = DenoSubcommand :: Cache ( CacheFlags { files } ) ;
3779
3796
}
@@ -4576,6 +4593,7 @@ fn runtime_args_parse(
4576
4593
) {
4577
4594
compile_args_parse ( flags, matches) ;
4578
4595
cached_only_arg_parse ( flags, matches) ;
4596
+ frozen_lockfile_arg_parse ( flags, matches) ;
4579
4597
if include_perms {
4580
4598
permission_args_parse ( flags, matches) ;
4581
4599
}
@@ -4667,6 +4685,12 @@ fn cached_only_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) {
4667
4685
}
4668
4686
}
4669
4687
4688
+ fn frozen_lockfile_arg_parse ( flags : & mut Flags , matches : & mut ArgMatches ) {
4689
+ if let Some ( & v) = matches. get_one :: < bool > ( "frozen" ) {
4690
+ flags. frozen_lockfile = v;
4691
+ }
4692
+ }
4693
+
4670
4694
fn ext_arg_parse ( flags : & mut Flags , matches : & mut ArgMatches ) {
4671
4695
flags. ext = matches. remove_one :: < String > ( "ext" ) ;
4672
4696
}
@@ -9845,4 +9869,33 @@ mod tests {
9845
9869
}
9846
9870
) ;
9847
9871
}
9872
+
9873
+ #[ test]
9874
+ fn run_with_frozen_lockfile ( ) {
9875
+ let cases = [
9876
+ ( Some ( "--frozen" ) , true ) ,
9877
+ ( Some ( "--frozen=true" ) , true ) ,
9878
+ ( Some ( "--frozen=false" ) , false ) ,
9879
+ ( None , false ) ,
9880
+ ] ;
9881
+ for ( flag, frozen) in cases {
9882
+ let mut args = svec ! [ "deno" , "run" ] ;
9883
+ if let Some ( f) = flag {
9884
+ args. push ( f. into ( ) ) ;
9885
+ }
9886
+ args. push ( "script.ts" . into ( ) ) ;
9887
+ let r = flags_from_vec ( args) ;
9888
+ assert_eq ! (
9889
+ r. unwrap( ) ,
9890
+ Flags {
9891
+ subcommand: DenoSubcommand :: Run ( RunFlags :: new_default(
9892
+ "script.ts" . to_string( ) ,
9893
+ ) ) ,
9894
+ frozen_lockfile: frozen,
9895
+ code_cache_enabled: true ,
9896
+ ..Flags :: default ( )
9897
+ }
9898
+ ) ;
9899
+ }
9900
+ }
9848
9901
}
0 commit comments