Skip to content

Commit 2f26eaf

Browse files
Spencerspalger
andauthored
[ts/checkTsProjects] produce a more useful error message (#83209)
Co-authored-by: spalger <[email protected]>
1 parent 5e06f43 commit 2f26eaf

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/dev/typescript/run_check_ts_projects_cli.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import { resolve } from 'path';
20+
import { resolve, relative } from 'path';
2121

2222
import execa from 'execa';
2323

@@ -35,7 +35,7 @@ export async function runCheckTsProjectsCli() {
3535
});
3636

3737
const isNotInTsProject: File[] = [];
38-
const isInMultipleTsProjects: File[] = [];
38+
const isInMultipleTsProjects: string[] = [];
3939

4040
for (const lineRaw of files.split('\n')) {
4141
const line = lineRaw.trim();
@@ -56,7 +56,11 @@ export async function runCheckTsProjectsCli() {
5656
isNotInTsProject.push(file);
5757
}
5858
if (projects.length > 1 && !file.isTypescriptAmbient()) {
59-
isInMultipleTsProjects.push(file);
59+
isInMultipleTsProjects.push(
60+
` - ${file.getRelativePath()}:\n${projects
61+
.map((p) => ` - ${relative(process.cwd(), p.tsConfigPath)}`)
62+
.join('\n')}`
63+
);
6064
}
6165
}
6266

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

7680
if (isInMultipleTsProjects.length) {
81+
const details = isInMultipleTsProjects.join('\n');
7782
log.error(
78-
`The following files belong to multiple tsconfig.json files listed in src/dev/typescript/projects.ts\n${isInMultipleTsProjects
79-
.map((file) => ` - ${file.getRelativePath()}`)
80-
.join('\n')}`
83+
`The following files belong to multiple tsconfig.json files listed in src/dev/typescript/projects.ts\n${details}`
8184
);
8285
}
8386

0 commit comments

Comments
 (0)