-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ./ to relative paths to make it easier to understand
- Loading branch information
Showing
6 changed files
with
83 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { relative, isAbsolute } from 'path' | ||
import { fileURLToPath } from 'url' | ||
|
||
// Formats a file url or absolute path as relative path relative to the current working directory. | ||
// It will start with ./ or ../ if it's a relative path. | ||
// It might be an absolute path if it's on a different drive on windows. | ||
// When the argument is not a file url or a absolute path, it will return the argument as is. | ||
export function relativeToCwd(file: string): string | ||
export function relativeToCwd(file: null): null | ||
export function relativeToCwd(file: string | null): string | null | ||
export function relativeToCwd(file: string | null): string | null { | ||
if (!file) { | ||
return file | ||
} | ||
if (file.startsWith('file://')) { | ||
file = fileURLToPath(file) | ||
} else if (!isAbsolute(file)) { | ||
return file | ||
} | ||
const relPath = relative(process.cwd(), file) | ||
if (isAbsolute(relPath)) { | ||
return relPath | ||
} | ||
if (relPath.startsWith('../')) { | ||
return relPath | ||
} | ||
return './' + relPath | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Hide the method name when showing a stack trace in the error overlay or when displaying a stack trace in the console. | ||
export function isHiddenMethodName(methodName: string) { | ||
return /^(?:Object\.|Module\.)?(?:<anonymous>|eval|__TURBOPACK__module__evaluation__)$/.test( | ||
methodName | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters