changeset 6:19c4af287596

Fix default values for relative part
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 10 Sep 2018 16:54:29 +0200
parents 6c46515ee860
children 309cc6c0cd75
files +mpm/check.m +mpm/leave.m +mpm/set.m +mpm/subpaths.m
diffstat 4 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/+mpm/check.m	Mon Sep 10 16:35:17 2018 +0200
+++ b/+mpm/check.m	Mon Sep 10 16:54:29 2018 +0200
@@ -4,9 +4,13 @@
 %
 % Useful to put at the top of some scripts
 function check()
+    if ~exist('d', 'var') || isempty(d)
+        d = '';
+    end
+
     folders = split(path(), pathsep);
 
-    sp = mpm.subpaths();
+    sp = mpm.subpaths(d);
     for i = 1:length(sp)
         if ~isAtTop(sp{i}, fullfile(pwd, sp{i}), folders)
             error('Subpaths are not correctly set. Try running mpm.set()');
--- a/+mpm/leave.m	Mon Sep 10 16:35:17 2018 +0200
+++ b/+mpm/leave.m	Mon Sep 10 16:54:29 2018 +0200
@@ -1,7 +1,7 @@
 % Leave project in current folder
 function leave(d)
     if ~exist('d', 'var') || isempty(d)
-        d = pwd;
+        d = '';
     end
 
     state = mpm.load_state();
@@ -13,5 +13,5 @@
         state.added_paths.remove(subpath);
     end
 
-    mpm.save_state(state)
+    mpm.save_state(state);
 end
--- a/+mpm/set.m	Mon Sep 10 16:35:17 2018 +0200
+++ b/+mpm/set.m	Mon Sep 10 16:54:29 2018 +0200
@@ -1,7 +1,7 @@
 % Set project to current folder
 function set(d)
     if ~exist('d', 'var') || isempty(d)
-        d = pwd;
+        d = '';
     end
 
     state = mpm.load_state();
--- a/+mpm/subpaths.m	Mon Sep 10 16:35:17 2018 +0200
+++ b/+mpm/subpaths.m	Mon Sep 10 16:54:29 2018 +0200
@@ -1,9 +1,9 @@
 function sp = subpaths(d)
     if ~exist('d', 'var') || isempty(d)
-        d = pwd;
+        d = '';
     end
 
     % TODO: Nice error message if file doesn't exist
-    fstr = fileread('.subpaths');
+    fstr = fileread(fullfile(d, '.subpaths'));
     sp = splitlines(strtrim(fstr));
 end