-
Notifications
You must be signed in to change notification settings - Fork 2
Add installationMethod as optional output from installFexPackage #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,16 @@ | ||
| function packageTargetFolder = installFexPackage(toolboxIdentifier, installLocation, options) | ||
| function [packageTargetFolder, installationMethod] = installFexPackage(toolboxIdentifier, installLocation, options) | ||
| % installFexPackage - Install a FileExchange package | ||
| % | ||
| % This function installs a package from FileExchange. If the package is | ||
| % already present, it is added to the path, otherwise it is downloaded. | ||
| % | ||
| % installFexPackage(toolboxIdentifier, installLocation) | ||
| % [folder, method] = installFexPackage(toolboxIdentifier, installLocation) | ||
| % | ||
| % Output: | ||
| % packageTargetFolder - Path to the installed package folder, or | ||
| % string(missing) for mltbx packages (managed by MATLAB) | ||
| % installationMethod - "folder" for zip-extracted packages, | ||
| % "mltbx" for MATLAB toolbox packages | ||
|
|
||
| % Todo: | ||
| % [ ] Separate method for downloading | ||
|
|
@@ -22,10 +28,12 @@ | |
| end | ||
|
|
||
| % Check if toolbox is installed | ||
| [isInstalled, version] = matbox.setup.internal.fex.isToolboxInstalled(toolboxIdentifier, options.Version); | ||
| [isInstalled, version, toolboxFolder] = matbox.setup.internal.fex.isToolboxInstalled(toolboxIdentifier, options.Version); | ||
|
|
||
| if isInstalled | ||
| matlab.addons.enableAddon(toolboxIdentifier, version) | ||
| packageTargetFolder = toolboxFolder; | ||
| installationMethod = "mltbx"; | ||
|
Comment on lines
33
to
+36
|
||
| if options.Verbose | ||
| fprintf('Requirement "%s" is already installed. Skipping...\n', options.Title) | ||
| end | ||
|
|
@@ -80,6 +88,7 @@ | |
| [tempFilepath, C] = matbox.setup.internal.utility.tempsave(addonUrl, [toolboxIdentifier, '_temp.zip']); | ||
|
|
||
| packageTargetFolder = fullfile(installLocation, toolboxName); | ||
| installationMethod = "folder"; | ||
| if ~isfolder(packageTargetFolder); mkdir(packageTargetFolder); end | ||
| unzip(tempFilepath, packageTargetFolder); | ||
| if options.AddToPath | ||
|
|
@@ -97,7 +106,8 @@ | |
| fprintf(newline) | ||
| error('Failed to install "%s"...', toolboxName) | ||
| end | ||
| packageTargetFolder = 'n/a'; % todo | ||
| packageTargetFolder = string(missing); | ||
| installationMethod = "mltbx"; | ||
| end | ||
|
|
||
| delete(C) | ||
|
|
@@ -106,7 +116,9 @@ | |
| end | ||
|
|
||
| if ~nargout | ||
| clear packageTargetFolder | ||
| clear packageTargetFolder installationMethod | ||
| elseif nargout == 1 | ||
| clear installationMethod | ||
| end | ||
| end | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring says
packageTargetFolderisstring(missing)for mltbx packages, but when the add-on is already installed you returntoolboxFolder(which can be""if the internal lookup fails). This makes the output contract inconsistent across the two mltbx paths; consider either always returningstring(missing)for mltbx, or updating the docs and normalizingtoolboxFolder==""tostring(missing)before returning.