@@ -155,6 +155,14 @@ module Args = struct
155155 value & opt dir default & info [" contents-dir" ] ~docv: " DIR" ~doc:
156156 " directory containing the base learn-ocaml app contents"
157157
158+ let editor_dir =
159+ let default =
160+ readlink (Filename. dirname (Filename. dirname (Sys. executable_name))
161+ / " share" / " learn-ocaml" / " editor" )
162+ in
163+ value & opt dir default & info [" editor-dir" ] ~docv: " DIR" ~doc:
164+ " directory containing the learn-ocaml-editor app contents"
165+
158166 let enable opt doc =
159167 value & vflag None [
160168 Some true , info [" enable-" ^ opt] ~doc: (" Enable " ^ doc);
@@ -195,6 +203,7 @@ module Args = struct
195203
196204 type t = {
197205 contents_dir : string ;
206+ editor_dir : string ;
198207 try_ocaml : bool option ;
199208 lessons : bool option ;
200209 editor : bool option ;
@@ -206,10 +215,10 @@ module Args = struct
206215
207216 let builder_conf =
208217 let apply
209- contents_dir try_ocaml lessons editor exercises playground toplevel base_url
210- = { contents_dir; try_ocaml; lessons; editor; exercises; playground; toplevel; base_url }
218+ contents_dir editor_dir try_ocaml lessons editor exercises playground toplevel base_url
219+ = { contents_dir; editor_dir; try_ocaml; lessons; editor; exercises; playground; toplevel; base_url }
211220 in
212- Term. (const apply $ contents_dir $ try_ocaml $ lessons $ editor $ exercises $ playground $ toplevel $ base_url)
221+ Term. (const apply $ contents_dir $ editor_dir $ try_ocaml $ lessons $ editor $ exercises $ playground $ toplevel $ base_url)
213222
214223 let repo_conf =
215224 let apply repo_dir exercises_filtered jobs =
@@ -309,17 +318,22 @@ let main o =
309318 else Lwt. return_none
310319 in
311320 let generate () =
321+ let copy title src_dir =
322+ Printf. printf " Updating %s at %s\n %!" title o.app_dir;
323+ Lwt. catch
324+ (fun () -> Lwt_utils. copy_tree src_dir o.app_dir)
325+ (function
326+ | Failure _ ->
327+ Lwt. fail_with @@
328+ Printf. sprintf " Failed to copy %s app contents from %s"
329+ title (readlink src_dir)
330+ | e -> Lwt. fail e)
331+ in
312332 if List. mem Build o.commands then
313- (Printf. printf " Updating app at %s\n %!" o.app_dir;
314- Lwt. catch
315- (fun () -> Lwt_utils. copy_tree o.builder.Builder. contents_dir o.app_dir)
316- (function
317- | Failure _ ->
318- Lwt. fail_with @@ Printf. sprintf
319- " Failed to copy base app contents from %s"
320- (readlink o.builder.Builder. contents_dir)
321- | e -> Lwt. fail e)
322- >> = fun () ->
333+ (copy " learn-ocaml" o.builder.Builder. contents_dir >> = fun () ->
334+ (if o.builder.Builder. editor <> Some false then
335+ copy " learn-ocaml-editor" o.builder.Builder. editor_dir
336+ else Lwt. return_unit) >> = fun () ->
323337 let server_config = o.repo_dir/ " server_config.json"
324338 and www_server_config = o.app_dir/ " server_config.json" in
325339 let module ServerData = Learnocaml_data. Server in
0 commit comments