import * as path from 'path' ; /**
 * Options for  Path . formatConcisely .
 *  public export interface IPathFormatConciselyOptions { /**
     * The path to be converted.
     */ pathToConvert : string ; /**
     * The base path to use when converting `pathToConvert` to a relative path.
     */ baseFolder : string ; } remarks public export class Path { private static _relativePathRegex : RegExp = /^[.\/\\]+$/ ; private static _upwardPathSegmentRegex : RegExp = /([\/\\]|^)\.\.([\/\\]|$)/ ; remarks public static isUnder ( childPath , parentFolderPath ) { const relativePath = path . relative ( childPath , parentFolderPath ) ; return Path . _relativePathRegex . test ( relativePath ) ; } remarks public static isUnderOrEqual ( childPath , parentFolderPath ) { const relativePath = path . relative ( childPath , parentFolderPath ) ; return relativePath === '' || Path . _relativePathRegex . test ( relativePath ) ; } remarks public static isEqual ( path1 , path2 ) { return path . relative ( path1 , path2 ) === '' ; } remarks public static formatConcisely ( options ) { const relativePath = path . relative ( options . pathToConvert , options . baseFolder ) ; const isUnderOrEqual = relativePath === '' || Path . _relativePathRegex . test ( relativePath ) ; if ( isUnderOrEqual ) { return './' + Path . convertToSlashes ( path . relative ( options . baseFolder , options . pathToConvert ) ) ; } const absolutePath = path . resolve ( options . pathToConvert ) ; return absolutePath ; } remarks public static convertToSlashes ( inputPath ) { return inputPath . replace ( /\\/g , '/' ) ; } remarks public static convertToBackslashes ( inputPath ) { return inputPath . replace ( /\//g , '\\' ) ; } example public static isDownwardRelative ( inputPath ) { if ( path . isAbsolute ( inputPath ) ) { return false ; } if ( Path . _upwardPathSegmentRegex . test ( inputPath ) ) { return false ; } return true ; } }