aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/unit/build_spec.lua (renamed from spec/unit_build_spec.lua)0
-rw-r--r--spec/unit/dir_spec.lua (renamed from spec/dir_spec.lua)0
-rw-r--r--spec/unit/fetch_spec.lua (renamed from spec/fetch_spec.lua)0
-rw-r--r--spec/unit/fs_spec.lua (renamed from spec/fs_spec.lua)0
-rw-r--r--spec/unit/fun_spec.lua (renamed from spec/fun_spec.lua)0
-rw-r--r--spec/unit/persist_spec.lua (renamed from spec/persist_spec.lua)0
-rw-r--r--spec/unit/rockspecs_spec.lua (renamed from spec/rockspecs_spec.lua)0
-rw-r--r--spec/unit/sysdetect_spec.lua (renamed from spec/sysdetect_spec.lua)0
-rw-r--r--spec/unit/tools_spec.lua (renamed from spec/tools_spec.lua)0
-rw-r--r--src/luarocks/fs/tools.lua16
10 files changed, 11 insertions, 5 deletions
diff --git a/spec/unit_build_spec.lua b/spec/unit/build_spec.lua
index 6ab143c6..6ab143c6 100644
--- a/spec/unit_build_spec.lua
+++ b/spec/unit/build_spec.lua
diff --git a/spec/dir_spec.lua b/spec/unit/dir_spec.lua
index b5dadda8..b5dadda8 100644
--- a/spec/dir_spec.lua
+++ b/spec/unit/dir_spec.lua
diff --git a/spec/fetch_spec.lua b/spec/unit/fetch_spec.lua
index 38da379e..38da379e 100644
--- a/spec/fetch_spec.lua
+++ b/spec/unit/fetch_spec.lua
diff --git a/spec/fs_spec.lua b/spec/unit/fs_spec.lua
index aea86af3..aea86af3 100644
--- a/spec/fs_spec.lua
+++ b/spec/unit/fs_spec.lua
diff --git a/spec/fun_spec.lua b/spec/unit/fun_spec.lua
index 9844ec27..9844ec27 100644
--- a/spec/fun_spec.lua
+++ b/spec/unit/fun_spec.lua
diff --git a/spec/persist_spec.lua b/spec/unit/persist_spec.lua
index f426fd83..f426fd83 100644
--- a/spec/persist_spec.lua
+++ b/spec/unit/persist_spec.lua
diff --git a/spec/rockspecs_spec.lua b/spec/unit/rockspecs_spec.lua
index 5b0573fe..5b0573fe 100644
--- a/spec/rockspecs_spec.lua
+++ b/spec/unit/rockspecs_spec.lua
diff --git a/spec/sysdetect_spec.lua b/spec/unit/sysdetect_spec.lua
index 6ec6f6b6..6ec6f6b6 100644
--- a/spec/sysdetect_spec.lua
+++ b/spec/unit/sysdetect_spec.lua
diff --git a/spec/tools_spec.lua b/spec/unit/tools_spec.lua
index 29e21740..29e21740 100644
--- a/spec/tools_spec.lua
+++ b/spec/unit/tools_spec.lua
diff --git a/src/luarocks/fs/tools.lua b/src/luarocks/fs/tools.lua
index a7724dc7..23f2561e 100644
--- a/src/luarocks/fs/tools.lua
+++ b/src/luarocks/fs/tools.lua
@@ -48,12 +48,11 @@ do
48 end 48 end
49end 49end
50 50
51local current_dir_with_cache
51do 52do
52 local cache_pwd 53 local cache_pwd
53 --- Obtain current directory. 54
54 -- Uses the module's internal directory stack. 55 current_dir_with_cache = function()
55 -- @return string: the absolute pathname of the current directory.
56 function tools.current_dir()
57 local current = cache_pwd 56 local current = cache_pwd
58 if not current then 57 if not current then
59 local pipe = io.popen(fs.quiet_stderr(vars.PWD)) 58 local pipe = io.popen(fs.quiet_stderr(vars.PWD))
@@ -66,6 +65,13 @@ do
66 end 65 end
67 return current, cache_pwd 66 return current, cache_pwd
68 end 67 end
68
69 --- Obtain current directory.
70 -- Uses the module's internal directory stack.
71 -- @return string: the absolute pathname of the current directory.
72 function tools.current_dir()
73 return (current_dir_with_cache()) -- drop second return
74 end
69end 75end
70 76
71--- Change the current directory. 77--- Change the current directory.
@@ -107,7 +113,7 @@ end
107-- @return boolean: true if command succeeds (status code 0), false 113-- @return boolean: true if command succeeds (status code 0), false
108-- otherwise. 114-- otherwise.
109function tools.execute_string(cmd) 115function tools.execute_string(cmd)
110 local current, cache_pwd = fs.current_dir() 116 local current, cache_pwd = current_dir_with_cache()
111 if not current then return false end 117 if not current then return false end
112 if current ~= cache_pwd then 118 if current ~= cache_pwd then
113 cmd = fs.command_at(current, cmd) 119 cmd = fs.command_at(current, cmd)