Ignore all directories starting with '.' pr '_'
This commit is contained in:
parent
503bc4532b
commit
c6dac87ee9
|
@ -111,9 +111,14 @@ will be automatically installed as well.
|
|||
jbuild-ignore
|
||||
=============
|
||||
|
||||
By default Jbuilder traverses the whole source tree. To ignore a
|
||||
subtree, simply write a ``jbuild-ignore`` file in the parent directory
|
||||
containing the name of the sub-directories to ignore.
|
||||
By default Jbuilder traverses the whole source tree, ignoring the
|
||||
following files and directories:
|
||||
|
||||
- any file that start with ``.#``
|
||||
- any directory that start with either ``.`` or ``_``
|
||||
|
||||
To ignore a subtree, simply write a ``jbuild-ignore`` file in the
|
||||
parent directory containing the name of the sub-directories to ignore.
|
||||
|
||||
So for instance, if you write ``foo`` in ``src/jbuild-ignore``, then
|
||||
``src/foo`` won't be traversed and any ``jbuild`` file it contains will
|
||||
|
|
|
@ -35,25 +35,24 @@ type t =
|
|||
|
||||
let root t = t.root
|
||||
|
||||
let ignore_file = function
|
||||
| ""
|
||||
| "_opam"
|
||||
| "_build"
|
||||
| ".git"
|
||||
| ".hg"
|
||||
| "_darcs"
|
||||
| "." -> true
|
||||
| fn -> fn.[0] = '.' && fn.[1] = '#'
|
||||
let ignore_file fn ~is_directory =
|
||||
fn = "" || fn = "." ||
|
||||
(is_directory && (fn.[0] = '.' || fn.[0] = '_')) ||
|
||||
(fn.[0] = '.' && fn.[1] = '#')
|
||||
|
||||
let load path =
|
||||
let rec walk path : Dir.t =
|
||||
let files, sub_dirs =
|
||||
Path.readdir path
|
||||
|> List.filter ~f:(fun fn ->
|
||||
not (ignore_file fn))
|
||||
|> List.partition_map ~f:(fun fn ->
|
||||
|> List.filter_map ~f:(fun fn ->
|
||||
let path = Path.relative path fn in
|
||||
if Path.exists path && Path.is_directory path then
|
||||
let is_directory = Path.exists path && Path.is_directory path in
|
||||
if ignore_file fn ~is_directory then
|
||||
None
|
||||
else
|
||||
Some (fn, path, is_directory))
|
||||
|> List.partition_map ~f:(fun (fn, path, is_directory) ->
|
||||
if is_directory then
|
||||
Inr (fn, walk path)
|
||||
else
|
||||
Inl fn)
|
||||
|
|
Loading…
Reference in New Issue