@@ -86,23 +86,32 @@ const SetCommand = Command.extend({
8686});
8787
8888function updateLintForPrefix(filePath: string, prefix: string): void {
89- const tsLint = JSON.parse(fs.readFileSync(filePath, 'utf8'));
90- const componentLint = tsLint.rules['component-selector'][2];
91- if (componentLint instanceof Array) {
92- tsLint.rules['component-selector'][2].push(prefix);
93- } else {
94- tsLint.rules['component-selector'][2] = prefix;
95- }
89+ if (!fs.existsSync(filePath)) {
90+ return;
91+ }
9692
97- const directiveLint = tsLint.rules['directive-selector'][2];
98- if (directiveLint instanceof Array) {
99- tsLint.rules['directive-selector'][2].push(prefix);
100- } else {
101- tsLint.rules['directive-selector'][2] = prefix;
102- }
103- fs.writeFileSync(filePath, JSON.stringify(tsLint, null, 2));
104- console.log(chalk.yellow(oneLine`we have updated tslint to match prefix,
105- you may want to fix linting errors.`));
93+ const tsLint = JSON.parse(fs.readFileSync(filePath, 'utf8'));
94+
95+ const componentLint = tsLint.rules['component-selector'][2];
96+ if (componentLint instanceof Array) {
97+ tsLint.rules['component-selector'][2].push(prefix);
98+ } else {
99+ tsLint.rules['component-selector'][2] = prefix;
100+ }
101+
102+ const directiveLint = tsLint.rules['directive-selector'][2];
103+ if (directiveLint instanceof Array) {
104+ tsLint.rules['directive-selector'][2].push(prefix);
105+ } else {
106+ tsLint.rules['directive-selector'][2] = prefix;
107+ }
108+
109+ fs.writeFileSync(filePath, JSON.stringify(tsLint, null, 2));
110+
111+ console.log(chalk.yellow(oneLine`
112+ tslint configuration updated to match new prefix,
113+ you may need to fix any linting errors.
114+ `));
106115}
107116
108117function parseValue(rawValue: string, path: string) {
0 commit comments