Skip to content

Commit

Permalink
Show a warning and exit if neither site dir nor default template exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbaturin committed Jul 20, 2019
1 parent da79f2f commit 3a0591a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/soupault.ml
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,21 @@ let get_args settings =
let settings = {settings with verbose = !verbose; strict = !strict} in
if !init then (Project_init.init settings; exit 0) else Ok settings

let check_project_dir settings =
if (not (FU.test FU.Exists settings.default_template)) &&
(not (FU.test FU.Is_dir settings.site_dir)) then
Logs.warn @@ fun m -> m "Site directory %s and default template %s do not exist"
settings.site_dir settings.default_template;
Logs.warn @@ fun m -> m "Use %s --init to initialize a basic project" Sys.argv.(0);
exit 1

let initialize () =
let settings = Defaults.default_settings in
let () = setup_logging settings.verbose in
let%m config = Config.read_config Defaults.config_file in
let settings = Config.update_settings settings config in
let%m settings = get_args settings in
let () = check_project_dir settings in
let%m widgets = Widgets.get_widgets config in
let%m default_template_str = Utils.get_file_content settings.default_template in
let default_env = {template=default_template_str; nav_path=[]; page_file=""} in
Expand Down

0 comments on commit 3a0591a

Please sign in to comment.