Function pathAbsoluteToRelativeCwd

  • If the filepath is somewhere in the current working directory, it can be converted into a relative path.

    Parameters

    • absolute: string

      the absolute filepath to convert.

    • workingDirectory: string = ...

      The directory relative to which the path should be converted. Defaults to the current working directory.

    Returns string

    The relative path.

    Remarks

    This function takes an absolute path as input and returns a relative path. It replaces the current working directory in the path with an empty string, replaces all backslashes with forward slashes, and removes any leading forward slashes.

    Example

    pathAbsoluteToRelativeCwd(__filename)
    //=> 'src/pathAbsoluteToRelativeCwd.ts'

Generated using TypeDoc