Skip to content

Commit bf479d7

Browse files
committed
build: try and map the found files back to the src folder
1 parent 1ff3788 commit bf479d7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

devops/build/check-path-length.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ function checkPathLength(dir) {
2828
hasError = true;
2929

3030
if (IS_AZURE_PIPELINES) {
31-
console.error(`##vso[task.logissue type=error;sourcepath=${filePath};]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`);
31+
console.error(`##vso[task.logissue type=error;sourcepath=${mapFileToSourcePath(filePath)};]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`);
3232
} else if (IS_GITHUB_ACTIONS) {
33-
console.error(`::error file=${filePath},title=Path exceeds ${MAX_PATH_LENGTH} characters::Paths should not be longer than ${MAX_PATH_LENGTH} characters to support WIN32 systems. The file ${filePath} exceeds that with ${filePath.length - MAX_PATH_LENGTH} characters.`);
33+
console.error(`::error file=${mapFileToSourcePath(filePath)},title=Path exceeds ${MAX_PATH_LENGTH} characters::Paths should not be longer than ${MAX_PATH_LENGTH} characters to support WIN32 systems. The file ${filePath} exceeds that with ${filePath.length - MAX_PATH_LENGTH} characters.`);
3434
} else {
3535
console.error(`Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${FILE_PATH_COLOR}`, filePath, filePath.length - MAX_PATH_LENGTH);
3636
}
@@ -47,6 +47,16 @@ function checkPathLength(dir) {
4747
return hasError;
4848
}
4949

50+
/**
51+
* Maps a file path to a source path for CI logs.
52+
* @remark This might not always work as expected, especially on bundled files, but it's a best effort to map the file path to a source path.
53+
* @param {string} file - The file path to map to a source path
54+
* @returns {string}
55+
*/
56+
function mapFileToSourcePath(file) {
57+
return file.replace(PROJECT_DIR, 'src');
58+
}
59+
5060
const hasError = checkPathLength(PROJECT_DIR, MAX_PATH_LENGTH);
5161

5262
if (hasError) {

0 commit comments

Comments
 (0)