This repository was archived by the owner on Mar 22, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
112112chdir :: FilePath -> Lua ()
113113chdir 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
120116env :: Lua NumResults
121117env = 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
129129getenv :: String -> Lua (Optional String )
130130getenv name = ioToLua (Optional <$> Env. lookupEnv name)
Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ assert(type(system.compiler_name) == 'string')
99assert (type (system .compiler_version ) == ' table' )
1010assert (type (system .os ) == ' string' )
1111
12- -- currentdir
13- assert (type (system .currentdir ()) == ' string' )
12+ -- getwd
13+ assert (type (system .getwd ()) == ' string' )
1414
1515-- env
1616assert (type (system .env ()) == ' table' )
@@ -24,7 +24,7 @@ assert(pcall(system.ls, 'README.md') == false)
2424
2525-- mkdir and rmdir
2626function 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 )
You can’t perform that action at this time.
0 commit comments