BLUE
PHP 7.4.33
Path:
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/tsconfig-paths/src
Run
Logout
Edit File
Size: 3.20 KB
Close
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/tsconfig-paths/src/try-path.ts
Text
Base64
import * as path from "path"; import { MappingEntry } from "./mapping-entry"; import { dirname } from "path"; import { removeExtension } from "./filesystem"; export interface TryPath { readonly type: "file" | "extension" | "index" | "package"; readonly path: string; } /** * Builds a list of all physical paths to try by: * 1. Check for file named exactly as request. * 2. Check for files named as request ending in any of the extensions. * 3. Check for file specified in package.json's main property. * 4. Check for files named as request ending in "index" with any of the extensions. */ export function getPathsToTry( extensions: ReadonlyArray<string>, absolutePathMappings: ReadonlyArray<MappingEntry>, requestedModule: string ): ReadonlyArray<TryPath> | undefined { if (!absolutePathMappings || !requestedModule || requestedModule[0] === ".") { return undefined; } const pathsToTry: Array<TryPath> = []; for (const entry of absolutePathMappings) { const starMatch = entry.pattern === requestedModule ? "" : matchStar(entry.pattern, requestedModule); if (starMatch !== undefined) { for (const physicalPathPattern of entry.paths) { const physicalPath = physicalPathPattern.replace("*", starMatch); pathsToTry.push({ type: "file", path: physicalPath }); pathsToTry.push( ...extensions.map( (e) => ({ type: "extension", path: physicalPath + e } as TryPath) ) ); pathsToTry.push({ type: "package", path: path.join(physicalPath, "/package.json"), }); const indexPath = path.join(physicalPath, "/index"); pathsToTry.push( ...extensions.map( (e) => ({ type: "index", path: indexPath + e } as TryPath) ) ); } } } return pathsToTry.length === 0 ? undefined : pathsToTry; } // Not sure why we don't just return the full found path? export function getStrippedPath(tryPath: TryPath): string { return tryPath.type === "index" ? dirname(tryPath.path) : tryPath.type === "file" ? tryPath.path : tryPath.type === "extension" ? removeExtension(tryPath.path) : tryPath.type === "package" ? tryPath.path : exhaustiveTypeException(tryPath.type); } export function exhaustiveTypeException(check: never): never { throw new Error(`Unknown type ${check}`); } /** * Matches pattern with a single star against search. * Star must match at least one character to be considered a match. * @param patttern for example "foo*" * @param search for example "fooawesomebar" * @returns the part of search that * matches, or undefined if no match. */ function matchStar(pattern: string, search: string): string | undefined { if (search.length < pattern.length) { return undefined; } if (pattern === "*") { return search; } const star = pattern.indexOf("*"); if (star === -1) { return undefined; } const part1 = pattern.substring(0, star); const part2 = pattern.substring(star + 1); if (search.substr(0, star) !== part1) { return undefined; } if (search.substr(search.length - part2.length) !== part2) { return undefined; } return search.substr(star, search.length - part2.length); }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 10
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__tests__
DIR
-
drwxr-xr-x
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
config-loader.ts
2.41 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
filesystem.ts
2.00 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.ts
522 B
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
mapping-entry.ts
1.95 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
match-path-async.ts
5.62 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
match-path-sync.ts
4.29 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
options.ts
304 B
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
register.ts
2.48 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
try-path.ts
3.20 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
tsconfig-loader.ts
5.67 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).