getCurrentWorkDirectory
Returns the current working directory. This version returns an Either result. If you prefer throwing behavior, use getCurrentWorkDirectoryOrThrow.
Example
ts
import { getCurrentWorkDirectory } from "@duplojs/server-utils";
import { E, unwrap } from "@duplojs/utils";
const result = getCurrentWorkDirectory();
// currentPath: E.Error<unknown> | E.Success<string>
if (E.isRight(result)) {
const currentPath = unwrap(result);
// currentPath: string
}Other examples
Throw variant
ts
import { getCurrentWorkDirectoryOrThrow } from "@duplojs/server-utils";
const currentPath = getCurrentWorkDirectoryOrThrow();
// currentPath: stringSyntax
typescript
function getCurrentWorkDirectory(): E.Error<unknown> | E.Success<string>Parameters
This function takes no parameters.
Return value
E.Success<string>: the absolute path of the current directory.E.Error<unknown>: if reading the current directory fails.
See also
setCurrentWorkingDirectory- Changes the current working directory.
