Skip to content

Commit

Permalink
Merge pull request #109 from samoht/doc
Browse files Browse the repository at this point in the history
Fix doc generation
  • Loading branch information
samoht committed Oct 16, 2018
2 parents 927fb80 + 626110a commit cef9f7e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/github.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,22 @@ let publish_in_git_branch ~dry_run ~remote ~branch ~name ~version ~docdir ~dir =
let cp src dst =
let src = Fpath.(cwd // src) in
let src = Fpath.to_dir_path src in
(* FIXME we lost Windows friends here, fix bos #30 *)
Sos.run ~dry_run Cmd.(v "cp" % "-R" % p src % p dst)
let rec copy_dir src dst =
OS.Dir.contents ~dotfiles:true ~rel:true src >>= fun files ->
List.fold_left (fun acc file ->
acc >>= fun () ->
let src = Fpath.(src // file) in
let dst = Fpath.(dst // file) in
OS.File.exists src >>= function
| false ->
Sos.mkdir ~dry_run dst >>= fun _ ->
copy_dir src dst
| true ->
Sos.read_file ~dry_run src >>= fun file ->
Sos.write_file ~dry_run dst file
) (Ok ()) files
in
copy_dir src dst
in
let delete dir =
if not (Fpath.is_current_dir dir) then Sos.delete_dir ~dry_run dir else
Expand Down
8 changes: 8 additions & 0 deletions lib/sos.ml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ let with_dir ~dry_run dir f x =
let _ = show "chdir %a" Fpath.pp dir in
Ok (f x)

let mkdir ~dry_run dir =
if not dry_run then OS.Dir.create dir
else match OS.Dir.exists dir with
| Ok true -> Ok true
| _ ->
let _ = show "mkdir %a" Fpath.pp dir in
Ok false

let file_must_exist ~dry_run f =
if not dry_run then OS.File.must_exist f
else
Expand Down
1 change: 1 addition & 0 deletions lib/sos.mli
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ val dir_exists: dry_run:bool -> Fpath.t -> (bool, error) result
val file_must_exist: dry_run:bool -> Fpath.t -> (Fpath.t, error) result

val out: 'a -> 'a * Bos.OS.Cmd.run_status
val mkdir: dry_run:bool -> Fpath.t -> (bool, error) result

0 comments on commit cef9f7e

Please sign in to comment.