Skip to content

Instantly share code, notes, and snippets.

@rpip
Last active December 20, 2015 23:08
Show Gist options
  • Save rpip/6209769 to your computer and use it in GitHub Desktop.
Save rpip/6209769 to your computer and use it in GitHub Desktop.
%% @doc Install the given module
install({Name, Repository}, Context) ->
Site = m_site:get(site, Context),
PrivDir = z_utils:lib_dir(priv),
SiteModulesDir = filename:join([PrivDir, "sites", Site, "modules"]),
ModuleDirname = SiteModulesDir ++ Site ++ Name,
case filelib:is_file(ModuleDirname) of
true ->
z_render:growl(?__("***ERROR: " ++ Name ++ " already installed.", Context), Context);
false ->
ZMM = filename:join([PrivDir, "bin", "zmm"]),
CMD = ZMM ++ " install -s " ++ Site,
os:cmd(CMD),
z_render:growl(?__(Name ++ " successfully installed.", Context), Context)
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment