Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mobeets committed Nov 9, 2017
1 parent fa8ea5d commit 5489fab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Download/clone this repo and add it to your Matlab path (using `addpath`). Now t

- `mpm install [package-name]`: install package by name
- `mpm uninstall [package-name]`: remove package, if installed
- `mpm search [package-name]`: find url given package name
- `mpm search [package-name]`: search for package given name (checks Github and Matlab File Exchange)
- `mpm freeze`: lists all packages currently installed
- `mpm init`: adds all installed packages to path (for running on Matlab startup)
- `mpm init`: adds all installed packages to path (run when Matlab starts up)

## More details

Expand Down
19 changes: 13 additions & 6 deletions mpm.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function mpm(action, varargin)
% find url if not set
if isempty(pkg.url)
pkg.url = findUrl(pkg, opts);
else % checks for .git and replaces
else
pkg.url = handleCustomUrl(pkg.url);
end

Expand Down Expand Up @@ -184,13 +184,19 @@ function listPackages(opts)
end

function url = handleCustomUrl(url)
% if .git url, must remove and add /zipball/master

% if .git url, must remove and add /zipball/master
inds = strfind(url, '.git');
if isempty(inds)
return;
inds = strfind(url, '?download=true');
if isempty(inds)
url = [url '?download=true'];
return;
end
end
ind = inds(end);
url = [url(1:ind-1) '/zipball/master' url(ind+4:end)];

end

function url = findUrl(pkg, opts)
Expand Down Expand Up @@ -661,7 +667,7 @@ function readRequirementsFile(fnm, opts)
error('Cannot set --nopaths because it is in infile.');
end
if ~isempty(line)
cmd = [line ' --installdir ' opts.installdir];
cmd = [line ' installdir ' opts.installdir];
if opts.force
cmd = [cmd ' --force'];
end
Expand All @@ -675,7 +681,7 @@ function readRequirementsFile(fnm, opts)
% verify
disp('About to run the following commands: ');
for ii = 1:numel(cmds)
disp([' mpm2 ' opts.action ' ' cmds{ii}]);
disp([' mpm ' opts.action ' ' cmds{ii}]);
end
reply = input('Confirm (y/n)? ', 's');
if isempty(reply)
Expand All @@ -688,6 +694,7 @@ function readRequirementsFile(fnm, opts)

% run all
for ii = 1:numel(cmds)
mpm(opts.action, cmds{ii});
cmd = strsplit(cmds{ii});
mpm(opts.action, cmd{:});
end
end

0 comments on commit 5489fab

Please sign in to comment.