angular/adev/shared-docs/pipeline/examples/shared/copyright.ts
Joey Perrott 2d8635d29d refactor(docs-infra): migrate @angular/docs from dev-infra into adev directory (#57132)
To increase the ease of development we are moving @angular/docs into the adev directory within this repo. While
we are doing this to improve our development experience in the short term, efforts are also in place
to maintain a division between this @angular/docs (shared) code and adev itself, so that it can be extracted
back out in the future when components is ready to leverage it as well.

PR Close #57132
2024-07-30 15:51:26 +00:00

43 lines
1.3 KiB
TypeScript

/*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
/** The pad used around the copyright blocks. */
const PAD = '\n\n';
/** The standard copyright block used throughout Angular. */
const COPYRIGHT = `
@license
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE file at https://angular.dev/license
`;
/** Copyright comment for CSS and Javascript/Typescript files. */
const CSS_TS_COPYRIGHT = `/*${COPYRIGHT}*/${PAD}`;
/** Copyright comment for HTML files. */
const HTML_COPYRIGHT = `<!--${COPYRIGHT}-->${PAD}`;
/**
* Append the copyright using the appropriate commenting structure based on the file extension.
*
* No copyright is appended if the type is unrecognized.
*/
export function appendCopyrightToFile(filename: string, content: string): string {
const extension = filename.split('.').pop();
switch (extension) {
case 'html':
case 'ng':
return `${HTML_COPYRIGHT}${content}`;
case 'js':
case 'ts':
case 'css':
case 'scss':
return `${CSS_TS_COPYRIGHT}${content}`;
default:
return content;
}
}