Skip to content

Commit

Permalink
[7.x] [ts/checkTsProjects] produce a more useful error message (#83209)…
Browse files Browse the repository at this point in the history
… (#83222)

Co-authored-by: spalger <spalger@users.noreply.github.com>
  • Loading branch information
Spencer and spalger authored Nov 11, 2020
1 parent 46552d2 commit 16db0f0
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 16db0f0

Please sign in to comment.