Skip to content

Commit 0e24419

Browse files
authored
optional chaining to prevent error during ng add
If there is no tslint.json an error occurs. With optional chaining we can catch that. Closes Issue #2
1 parent 5ae2726 commit 0e24419

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libs/ddd/src/schematics/utils/update-linting-rules.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function checkRuleExists(rules: object, context: SchematicContext) {
3232

3333
export function addDomainToLintingRules(domainName: string): Rule {
3434
return (host: Tree, context: SchematicContext) => {
35-
const text = host.read('tslint.json').toString();
35+
const text = host.read('tslint.json')?.toString();
3636
const rules = JSON.parse(text);
3737

3838
if (!checkRuleExists(rules, context)) return;
@@ -97,4 +97,4 @@ export function initLintingRules(): Rule {
9797
const newText = JSON.stringify(rules, undefined, 2);
9898
host.overwrite('tslint.json', newText);
9999
}
100-
}
100+
}

0 commit comments

Comments
 (0)