Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Options with dynamic JsObject #45

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal actual external fun fs_exists(path: String): Boolean

/** [docs](https://nodejs.org/api/fs.html#fsmkdirsyncpath-options) */
@JsName("mkdirSync")
internal external fun fs_mkdirSync(path: String, options: Options.Mkdir): String?
internal external fun fs_mkdirSync(path: String, options: dynamic): String?

/** [docs](https://nodejs.org/api/fs.html#fsreadfilesyncpath-options) */
@JsName("readFileSync")
Expand All @@ -41,11 +41,11 @@ internal external fun fs_realpathSync(path: String): String

/** [docs](https://nodejs.org/api/fs.html#fsrmsyncpath-options) */
@JsName("rmSync")
internal external fun fs_rmSync(path: String, options: Options.Remove)
internal external fun fs_rmSync(path: String, options: dynamic)

/** [docs](https://nodejs.org/api/fs.html#fsrmdirsyncpath-options) */
@JsName("rmdirSync")
internal external fun fs_rmdirSync(path: String, options: Options.Remove)
internal external fun fs_rmdirSync(path: String, options: dynamic)

/** [docs](https://nodejs.org/api/fs.html#fsunlinksyncpath) */
@JsName("unlinkSync")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,16 @@ internal actual fun fs_remove(path: String): Boolean {
if (t.errorCode == "ENOENT") return false
}

val options = js("{}")
options["force"] = true
options["recursive"] = false

return try {
fs_rmSync(path, Options.Remove(force = true, recursive = false))
fs_rmSync(path, options)
true
} catch (_: Throwable) {
try {
fs_rmdirSync(path, Options.Remove(force = true, recursive = false))
fs_rmdirSync(path, options)
true
} catch (t: Throwable) {
throw t.toIOException()
Expand All @@ -148,7 +152,11 @@ internal actual fun fs_remove(path: String): Boolean {

internal actual fun fs_mkdir(path: String): Boolean {
return try {
fs_mkdirSync(path, Options.Mkdir())
val options = js("{}")
options["recursive"] = false
options["mode"] = "775"

fs_mkdirSync(path, options)
true
} catch (_: Throwable) {
false
Expand Down

This file was deleted.

Loading