MCPcopy Index your code
hub / github.com/facebook/react / getValidFilePath

Function getValidFilePath

packages/react-devtools-core/src/editor.js:112–134  ·  view source on GitHub ↗
(
  maybeRelativePath: string,
  absoluteProjectRoots: Array<string>,
)

Source from the content-addressed store, hash-verified

110let childProcess = null;
111
112export function getValidFilePath(
113 maybeRelativePath: string,
114 absoluteProjectRoots: Array<string>,
115): string | null {
116 // We use relative paths at Facebook with deterministic builds.
117 // This is why our internal tooling calls React DevTools with absoluteProjectRoots.
118 // If the filename is absolute then we don't need to care about this.
119 if (isAbsolute(maybeRelativePath)) {
120 if (existsSync(maybeRelativePath)) {
121 return maybeRelativePath;
122 }
123 } else {
124 for (let i = 0; i < absoluteProjectRoots.length; i++) {
125 const projectRoot = absoluteProjectRoots[i];
126 const joinedPath = join(projectRoot, maybeRelativePath);
127 if (existsSync(joinedPath)) {
128 return joinedPath;
129 }
130 }
131 }
132
133 return null;
134}
135
136export function doesFilePathExist(
137 maybeRelativePath: string,

Callers 2

doesFilePathExistFunction · 0.85
launchEditorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected