fs.readdir / fs.readdirSync do not list correct files
dundalek opened this issue · 4 comments
When trying to list files in a directory with fs.readdir
or fs.readdirSync
in the latest 1.9.0
it returns #js ["LUMO__INTERNAL__CLASSPATH"]
instead of the directory contents:
Lumo 1.9.0
ClojureScript 1.10.439
Node.js v10.9.0
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Exit: Control+D or :cljs/quit or exit
cljs.user=> (def fs (js/require "fs"))
#'cljs.user/fs
cljs.user=> (fs.readdirSync ".")
#js ["LUMO__INTERNAL__CLASSPATH"]
cljs.user=> (fs.readdir "." (fn [err files] (js/console.log err files)))
nil
cljs.user=> null [ 'LUMO__INTERNAL__CLASSPATH' ]
However with 1.9.0-alpha
in the same directory it returns the list of files correctly:
Lumo 1.9.0-alpha
ClojureScript 1.10.238
Node.js v9.10.0
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Exit: Control+D or :cljs/quit or exit
cljs.user=> (def fs (js/require "fs"))
#'cljs.user/fs
cljs.user=> (fs.readdirSync ".")
#js [".circleci"
".cpcache"
".dockerignore"
".git"
".gitignore"
".idea"
".lein-repl-history"
".lumo_cache"
".nodemon.json"
".rebel_readline_history"
"CHANGELOG.md"
"Dockerfile"
...]
Oh no, this is really bad. Thanks for catching this, I’ll take a look during the weekend.
I have the similar problem on fs-extra/copySync
:
cljs.user=> (fs-extra/copySync "./" "../foo")
ENOENT: no such file or directory, lstat 'LUMO__INTERNAL__CLASSPATH'
...
Hello, great work on Lumo!
I was trying to write some scripts today and it seems this issue is still unresolved.
> lumo -c .
Lumo 1.9.0
ClojureScript 1.10.439
Node.js v10.9.0
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Exit: Control+D or :cljs/quit or exit
cljs.user=> (require '["shelljs" :as sh])
nil
cljs.user=> (sh/ls ".")
#js ["LUMO__INTERNAL__CLASSPATH"]
cljs.user=>
Is there any ETA for the fix, or is there any underlying problem that blocks this from easily getting fixed?
Thanks
This would seem as if the CWD is not properly set/propagated?
For absolute paths readdirSync
seems to work.
EDIT: nevermind, it works for /
but e.g. (fs.readdirSync (process.cwd))
produces the same error :/
The interesting thing is that it only affects the directory that lumo was started in, all other directories can be listed - from relative or absolute paths.