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
|
jbuild-ignore
|
||||||
=============
|
=============
|
||||||
|
|
||||||
By default Jbuilder traverses the whole source tree. To ignore a
|
By default Jbuilder traverses the whole source tree, ignoring the
|
||||||
subtree, simply write a ``jbuild-ignore`` file in the parent directory
|
following files and directories:
|
||||||
containing the name of the sub-directories to ignore.
|
|
||||||
|
- 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
|
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
|
``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 root t = t.root
|
||||||
|
|
||||||
let ignore_file = function
|
let ignore_file fn ~is_directory =
|
||||||
| ""
|
fn = "" || fn = "." ||
|
||||||
| "_opam"
|
(is_directory && (fn.[0] = '.' || fn.[0] = '_')) ||
|
||||||
| "_build"
|
(fn.[0] = '.' && fn.[1] = '#')
|
||||||
| ".git"
|
|
||||||
| ".hg"
|
|
||||||
| "_darcs"
|
|
||||||
| "." -> true
|
|
||||||
| fn -> fn.[0] = '.' && fn.[1] = '#'
|
|
||||||
|
|
||||||
let load path =
|
let load path =
|
||||||
let rec walk path : Dir.t =
|
let rec walk path : Dir.t =
|
||||||
let files, sub_dirs =
|
let files, sub_dirs =
|
||||||
Path.readdir path
|
Path.readdir path
|
||||||
|> List.filter ~f:(fun fn ->
|
|> List.filter_map ~f:(fun fn ->
|
||||||
not (ignore_file fn))
|
let path = Path.relative path fn in
|
||||||
|> List.partition_map ~f:(fun fn ->
|
let is_directory = Path.exists path && Path.is_directory path in
|
||||||
let path = Path.relative path fn in
|
if ignore_file fn ~is_directory then
|
||||||
if Path.exists path && Path.is_directory path 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)
|
Inr (fn, walk path)
|
||||||
else
|
else
|
||||||
Inl fn)
|
Inl fn)
|
||||||
|
|
Loading…
Reference in New Issue