test(compiler-cli): ensure that golden partial files are parsed accurately (#39939)
Previously files were serialized with an extra newline seperator that was not removed when parsing. This caused the parsed file to start with an extra newline that invalidated its source-map. Also, the splitting was producing an empty entry at the start of the extracted golden files which is now ignored. PR Close #39939
This commit is contained in:
parent
2afa3801bc
commit
c5ea3d5b0e
|
@ -11,7 +11,7 @@ const headerStart =
|
|||
' * PARTIAL FILE: ';
|
||||
|
||||
const headerEnd =
|
||||
'\n ****************************************************************************************************/';
|
||||
'\n ****************************************************************************************************/\n';
|
||||
|
||||
/**
|
||||
* Render the partially compiled files into a single golden partial output string.
|
||||
|
@ -19,7 +19,7 @@ const headerEnd =
|
|||
* @param files The partially compiled files to be rendered.
|
||||
*/
|
||||
export function renderGoldenPartial(files: PartiallyCompiledFile[]): string {
|
||||
return files.map(file => `${headerStart + file.path + headerEnd}\n${file.content}`).join('\n');
|
||||
return files.map(file => `${headerStart + file.path + headerEnd}${file.content}`).join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,9 @@ export function parseGoldenPartial(partialContent: string): PartiallyCompiledFil
|
|||
const partials = partialContent.split(headerStart);
|
||||
for (const partial of partials) {
|
||||
const [path, content] = partial.split(headerEnd);
|
||||
files.push({path, content});
|
||||
if (path) {
|
||||
files.push({path, content});
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue