Skip to main content

runWithCurrentDirectory

@webda/utils


Function: runWithCurrentDirectory()

runWithCurrentDirectory(dir, cb): any

Defined in: packages/utils/src/chdir.ts:13

Run a callback with the current working directory temporarily changed to dir.

Restores the original working directory after the callback completes, whether it returns synchronously, returns a Promise, or throws.

Parameters​

dir​

string

The directory to switch to before invoking the callback

cb​

() => any

The callback to execute in the new directory

Returns​

any

The return value of the callback (sync or Promise)