Skip to content

@jsvision/files / changeDir

Function: changeDir()

changeDir(host, opts?): Promise<string | null>

Defined in: files/src/openers.ts:99

Show a modal change-directory dialog and resolve to the chosen absolute directory, or null if the user cancels.

Parameters

host

ExecHost

A host that can run a view modally — the createApplication result works directly.

opts?

ChangeDirOptions = {}

Filesystem, starting directory, and title.

Returns

Promise<string | null>

The chosen absolute directory, or null on cancel.

Example

ts
import { createApplication } from '@jsvision/ui';
import { resolveCapabilities } from '@jsvision/core';
import { changeDir } from '@jsvision/files';

const caps = resolveCapabilities({ env: process.env, platform: process.platform }).profile;
const app = createApplication({ caps });

const dir = await changeDir(app, { directory: '/home/user' });
if (dir !== null) console.log('changed to', dir);