Skip to content

Commit

Permalink
[ts/checkTsProjects] produce a more useful error message (#83209)
Browse files Browse the repository at this point in the history
Co-authored-by: spalger <spalger@users.noreply.github.com>
  • Loading branch information
Spencer and spalger authored Nov 11, 2020
1 parent 5e06f43 commit 2f26eaf
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/dev/typescript/run_check_ts_projects_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { resolve } from 'path';
import { resolve, relative } from 'path';

import execa from 'execa';

Expand All @@ -35,7 +35,7 @@ export async function runCheckTsProjectsCli() {
});

const isNotInTsProject: File[] = [];
const isInMultipleTsProjects: File[] = [];
const isInMultipleTsProjects: string[] = [];

for (const lineRaw of files.split('\n')) {
const line = lineRaw.trim();
Expand All @@ -56,7 +56,11 @@ export async function runCheckTsProjectsCli() {
isNotInTsProject.push(file);
}
if (projects.length > 1 && !file.isTypescriptAmbient()) {
isInMultipleTsProjects.push(file);
isInMultipleTsProjects.push(
` - ${file.getRelativePath()}:\n${projects
.map((p) => ` - ${relative(process.cwd(), p.tsConfigPath)}`)
.join('\n')}`
);
}
}

Expand All @@ -74,10 +78,9 @@ export async function runCheckTsProjectsCli() {
}

if (isInMultipleTsProjects.length) {
const details = isInMultipleTsProjects.join('\n');
log.error(
`The following files belong to multiple tsconfig.json files listed in src/dev/typescript/projects.ts\n${isInMultipleTsProjects
.map((file) => ` - ${file.getRelativePath()}`)
.join('\n')}`
`The following files belong to multiple tsconfig.json files listed in src/dev/typescript/projects.ts\n${details}`
);
}

Expand Down

0 comments on commit 2f26eaf

Please sign in to comment.