Skip to content

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: string

Syntax ​

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 ​

Released under the MIT license.