The fully path of a TypeScript file. Can either a File URL or simple full path.
The desired path fragment off of the root.
OptionalfileName: stringOptional file name to append to the end of the path.
A path from the project root.
IMPORTANT NOTE: This function is for use only for CLI use in the dev environment. It will not work in a serverless deployment environment.
const markdownDataPath = getFullPath(
import.meta.url,
"tests\\test-data\\markdown"
)
or
const markdownDataPath = getFullPath(
"C:\\Users\\thumb\\Documents\\projects\\typescript\\utils\\src\\markdown.ts"
"tests\\test-data\\markdown"
)
If the filePath is
"C:\\Users\\thumb\\Documents\\projects\\typescript\\utils"
and the additionalPath is:
"tests\\test-data\\markdown"
The result is:
"C:\\Users\\thumb\\Documents\\projects\\typescript\\utils\\tests\\test-data\\markdown"
Get a path appeneded to the project root. This function makes it easy to get a file path inside a project for CLI work (mostly to read and write to JSON and markdown files). It dispenses with worrying about
../../nonsense.This function is for use specifically for CLI work. It does not work on serverless environments.