Skip to content

Commit

Permalink
[flow] Replace last with_default_lib_dir use with another filter
Browse files Browse the repository at this point in the history
Summary:
Instead of using the hack, we should just properly filter it away elsewhere.

Changelog: [internal]

Reviewed By: panagosg7

Differential Revision: D66383775

fbshipit-source-id: 85d0331e81822866bab0346f39b5ed72828a0f3f
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Nov 25, 2024
1 parent efe3518 commit 3441f53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/commands/lsCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ let get_ls_files ~root ~all ~options ~libs ~imaginary = function
let subdir = Some (File_path.make dir) in
Files.make_next_files ~sort:true ~root ~all ~subdir ~options ~include_libdef:false ~libs
| Some file ->
if (Sys.file_exists file || imaginary) && (all || wanted ~root ~options libs file) then
if
(Sys.file_exists file || imaginary)
(* Make flow ls never report flowlib files *)
&& (not (Files.is_in_flowlib options file))
&& (all || wanted ~root ~options libs file)
then
let file = file |> File_path.make |> File_path.to_string in
let rec cb =
ref (fun () ->
Expand Down Expand Up @@ -241,8 +246,6 @@ let main
let options =
make_options ~flowconfig ~root ~ignore_flag ~include_flag ~untyped_flag ~declaration_flag
in
(* Turn on --no-flowlib by default, so that flow ls never reports flowlib files *)
let options = Files.with_default_lib_dir ~default_lib_dir:None options in
let (_, libs) = Files.init options in
(* `flow ls` and `flow ls dir` will list out all the flow files. We want to include lib files, so
* we pass in ~libs:SSet.empty, which means we won't filter out any lib files *)
Expand Down
9 changes: 5 additions & 4 deletions src/common/files.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ let default_options =

let default_lib_dir options = options.default_lib_dir

let with_default_lib_dir ~default_lib_dir options = { options with default_lib_dir }

let ignores options = options.ignores

let untyped options = options.untyped
Expand Down Expand Up @@ -537,12 +535,15 @@ let is_in_flowlib (options : options) : string -> bool =
match options.default_lib_dir with
| None -> (fun _ -> false)
| Some libdir ->
let root =
let root_str =
match libdir with
| Prelude path
| Flowlib path ->
path
File_path.to_string path
in
(* Similar to the |> File_path.to_string |> File_path.make |> File_path.to_string indirection
* in init below, we need to do this to resolve symlinks. *)
let root = File_path.make root_str in
is_prefix (File_path.to_string root)

let init ?(flowlibs_only = false) (options : options) =
Expand Down
2 changes: 0 additions & 2 deletions src/common/files.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ val default_options : options

val default_lib_dir : options -> lib_dir option

val with_default_lib_dir : default_lib_dir:lib_dir option -> options -> options

val ignores : options -> (string * Str.regexp) list

val untyped : options -> (string * Str.regexp) list
Expand Down

0 comments on commit 3441f53

Please sign in to comment.