MCPcopy Create free account
hub / github.com/react-hook-form/react-hook-form / checkLineEndings

Function checkLineEndings

scripts/apiExtractor.js:63–89  ·  view source on GitHub ↗

* Checks the line endings of the API extractor report. * Exits with status code 1 if the line endings don't match the * API Extractor config. * @param config {ExtractorConfig}

(config)

Source from the content-addressed store, hash-verified

61 * @param config {ExtractorConfig}
62 */
63function checkLineEndings(config) {
64 const report = fs.readFileSync(config.reportFilePath);
65
66 const LF = '\n';
67 const CRLF = '\r\n';
68
69 const containsLf = report.includes(LF);
70 const containsCrLf = report.includes(CRLF);
71
72 const relativeReportPath = path.relative(
73 process.cwd(),
74 config.reportFilePath,
75 );
76
77 if (config.newlineKind === LF && containsCrLf) {
78 exit(
79 `${relativeReportPath} contains CRLF.`,
80 `Please convert its line endings to LF.`,
81 );
82 }
83 if (config.newlineKind === CRLF && containsLf && !containsCrLf) {
84 exit(
85 `${relativeReportPath} contains LF.`,
86 `Please convert its line endings to CRLF.`,
87 );
88 }
89}
90
91/**
92 * Finds and loads the API Extractor config relative to the

Callers 1

apiExtractor.jsFile · 0.85

Calls 1

exitFunction · 0.85

Tested by

no test coverage detected