function formatPathDisplay
formatPathDisplay(
file: string,
projectRoot: string
): string

A path as a person would say it: qunitx-cli/lib/repl/session.ts for something in this project, and the absolute path for anything outside it.

The project's own directory name leads, because lib/repl/session.ts alone is ambiguous the moment a session has .imported something from a sibling checkout — and the question this is asked in is one about running code.

import { formatPathDisplay } from './editor.ts';

formatPathDisplay('/home/me/proj/lib/a.ts', '/home/me/proj'); // 'proj/lib/a.ts'
formatPathDisplay('/etc/hosts', '/home/me/proj'); // '/etc/hosts' — outside, so say all of it

Parameters

file: string
projectRoot: string

Return Type

string

Usage

import { formatPathDisplay } from "lib/commands/repl/editor.ts";