Skip to content

Commit c0a53ba

Browse files
committed
feat(compiler): handle files with license headers
closes #1728
1 parent 84b1c7a commit c0a53ba

4 files changed

Lines changed: 57 additions & 2 deletions

File tree

‎src/app/compiler/angular-dependencies.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,8 +1630,9 @@ export class AngularDependencies extends FrameworkDependencies {
16301630
let description: string = '';
16311631
if (node.jsDoc) {
16321632
if (node.jsDoc.length > 0) {
1633-
if (typeof node.jsDoc[0].comment !== 'undefined') {
1634-
const rawDescription = this.jsdocParserUtil.parseJSDocNode(node.jsDoc[0]);
1633+
const lastJsDoc = node.jsDoc[node.jsDoc.length - 1];
1634+
if (typeof lastJsDoc.comment !== 'undefined') {
1635+
const rawDescription = this.jsdocParserUtil.parseJSDocNode(lastJsDoc);
16351636
description = markedAcl(rawDescription);
16361637
}
16371638
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @license
3+
* @copyright
4+
*/
5+
6+
/**
7+
* Does the thing.
8+
* @param a thing.
9+
* @param b thing.
10+
* @returns A thing.
11+
*/
12+
export function exampleFn(
13+
a: string,
14+
b: string,
15+
): unknown {
16+
return null;
17+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs"
4+
},
5+
"include": [
6+
"foo-with-license-header.function.ts"
7+
]
8+
}

‎test/src/cli/cli-coverage.spec.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,33 @@ describe('CLI coverage report', () => {
460460
);
461461
});
462462
});
463+
464+
describe('coverage regression - @license/@copyright header should not shadow function JSDoc', () => {
465+
let stdoutString = undefined;
466+
before(function (done) {
467+
tmp.create(distFolder);
468+
let ls = shell('node', [
469+
'./bin/index-cli.js',
470+
'-p',
471+
'./test/fixtures/sample-files/tsconfig.license-header.json',
472+
'--coverageMinimumPerFile',
473+
'100',
474+
'--coverageTestShowOnlyFailed',
475+
'-d',
476+
distFolder
477+
]);
478+
479+
if (ls.stderr.toString() !== '') {
480+
console.error(`shell error: ${ls.stderr.toString()}`);
481+
done('error');
482+
}
483+
stdoutString = ls.stdout.toString();
484+
done();
485+
});
486+
after(() => tmp.clean(distFolder));
487+
488+
it('should report 100% coverage for a documented function preceded by a @license/@copyright header', () => {
489+
expect(stdoutString).to.not.contain('under minimum per file');
490+
});
491+
});
463492
});

0 commit comments

Comments
 (0)