MCPcopy Create free account
hub / github.com/angular/dev-infra / readFileGracefully

Function readFileGracefully

ng-dev/utils/resolve-yarn-bin.ts:181–190  ·  view source on GitHub ↗

* Reads the specified file gracefully. * @returns The file contents. Null if the file does not exist.

(filePath: string)

Source from the content-addressed store, hash-verified

179 * @returns The file contents. Null if the file does not exist.
180 */
181async function readFileGracefully(filePath: string): Promise<string | null> {
182 try {
183 return await fs.promises.readFile(filePath, 'utf8');
184 } catch (error) {
185 if (isNodeJSWrappedError(error, Error) && error.code === 'ENOENT') {
186 return null;
187 }
188 throw error;
189 }
190}

Callers 1

Calls 1

isNodeJSWrappedErrorFunction · 0.90

Tested by

no test coverage detected