This commit is contained in:
Craig Everett 2018-05-31 21:09:34 +09:00
parent 948040cdcd
commit 3410bbbffb

View File

@ -286,28 +286,28 @@ assimilate2(CWD, PackageID) ->
log(info, Message, [PackageString]).
-spec set_dep(Identifier :: string()) -> zx:outcome().
-spec set_dep(PackageString :: string()) -> zx:outcome().
%% @private
%% Set a specific dependency in the current project. If the project currently has a
%% dependency on the same package then the version of that dependency is updated to
%% reflect that in the PackageString argument. The AppString is permitted to be
%% incomplete. Incomplete elements of the VersionString (if included) will default to
%% the latest version available at the indicated level.
%% Set a dependency in the current project. If the project currently has a dependency
%% on the same package then the version of that dependency is updated to reflect that
%% in the PackageString argument.
set_dep(Identifier) ->
{ok, {Realm, Name, FuzzyVersion}} = zx_lib:package_id(Identifier),
case FuzzyVersion of
{X, Y, Z} when is_integer(X), is_integer(Y), is_integer(Z) ->
set_dep({Realm, Name}, {X, Y, Z});
_ ->
{error, "Incompelte version tuple.", 22}
set_dep(PackageString) ->
case zx_lib:package_id(PackageString) of
{ok, {_, _, {_, _, z}}} ->
Message =
"Incomplete version tuple. Dependencies must be fully specified.",
{error, Message, 22};
{ok, PackageID} ->
set_dep2(PackageID);
{error, invalid_package_string} ->
{error, "Invalid package string", 22}
end.
-spec set_dep(zx:package(), zx:version()) -> ok.
-spec set_dep2(zx:package_id()) -> ok.
set_dep({Realm, Name}, Version) ->
PackageID = {Realm, Name, Version},
set_dep2(PackageID) ->
{ok, Meta} = zx_lib:read_project_meta(),
Deps = maps:get(deps, Meta),
case lists:member(PackageID, Deps) of