Skip to content
This repository was archived by the owner on Mar 22, 2021. It is now read-only.

Commit 72a710a

Browse files
committed
Rename currentdir to getwd
1 parent 23031dd commit 72a710a

3 files changed

Lines changed: 20 additions & 21 deletions

File tree

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@ Parameters:
5858
: Path of the directory which is to become the new working directory.
5959

6060

61-
### currentdir {#system-currentdir}
62-
63-
`currentdir ()`
64-
65-
Obtain the current working directory as an absolute path.
66-
67-
Returns:
68-
69-
- The current working directory (string).
70-
7161
### env {#system-env}
7262

7363
`env ()`
@@ -79,7 +69,6 @@ Returns:
7969
- A table mapping environment variables names to their string value
8070
(table).
8171

82-
### getenv {#system-getenv}
8372

8473
`getenv (var)`
8574

@@ -96,7 +85,17 @@ Returns:
9685
- value of the variable, or nil if the variable is not defined (string
9786
or nil).
9887

99-
### ls {#system-ls}
88+
### getwd
89+
90+
`getwd ()`
91+
92+
Obtain the current working directory as an absolute path.
93+
94+
Returns:
95+
96+
- The current working directory (string).
97+
98+
### ls
10099

101100
`ls ([directory])`
102101

src/Foreign/Lua/Module/System.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ module Foreign.Lua.Module.System (
2222

2323
-- * Functions
2424
, chdir
25-
, currentdir
2625
, env
26+
, getwd
2727
, getenv
2828
, ls
2929
, mkdir
@@ -63,9 +63,9 @@ pushModule = do
6363
addField "compiler_version" compiler_version
6464
addField "os" os
6565
addFunction "chdir" chdir
66-
addFunction "currentdir" currentdir
6766
addFunction "env" env
6867
addFunction "getenv" getenv
68+
addFunction "getwd" getwd
6969
addFunction "ls" ls
7070
addFunction "mkdir" mkdir
7171
addFunction "rmdir" rmdir
@@ -112,10 +112,6 @@ os = Info.os
112112
chdir :: FilePath -> Lua ()
113113
chdir fp = ioToLua $ Directory.setCurrentDirectory fp
114114

115-
-- | Return the current working directory.
116-
currentdir :: Lua FilePath
117-
currentdir = ioToLua Directory.getCurrentDirectory
118-
119115
-- | Retrieve the entire environment
120116
env :: Lua NumResults
121117
env = do
@@ -125,6 +121,10 @@ env = do
125121
mapM_ addValue kvs
126122
return (NumResults 1)
127123

124+
-- | Return the current working directory as an absolute path.
125+
getwd :: Lua FilePath
126+
getwd = ioToLua Directory.getCurrentDirectory
127+
128128
-- | Returns the value of an environment variable
129129
getenv :: String -> Lua (Optional String)
130130
getenv name = ioToLua (Optional <$> Env.lookupEnv name)

test/system-module-tests.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ assert(type(system.compiler_name) == 'string')
99
assert(type(system.compiler_version) == 'table')
1010
assert(type(system.os) == 'string')
1111

12-
-- currentdir
13-
assert(type(system.currentdir()) == 'string')
12+
-- getwd
13+
assert(type(system.getwd()) == 'string')
1414

1515
-- env
1616
assert(type(system.env()) == 'table')
@@ -24,7 +24,7 @@ assert(pcall(system.ls, 'README.md') == false)
2424

2525
-- mkdir and rmdir
2626
function in_tmpdir (callback)
27-
local orig_dir = system.currentdir()
27+
local orig_dir = system.getwd()
2828
return system.with_tmpdir(
2929
'hello',
3030
function (tmpdir)

0 commit comments

Comments
 (0)