Skip to content

Commit a6c2c1d

Browse files
committed
rearrange the flow a bit
1 parent bf479d7 commit a6c2c1d

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

devops/build/check-path-length.js

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ console.log('\n-----------------------------------');
1818
console.log('Results:');
1919
console.log('-----------------------------------\n');
2020

21+
const hasError = checkPathLength(PROJECT_DIR, MAX_PATH_LENGTH);
22+
23+
if (hasError) {
24+
console.log('\n-----------------------------------');
25+
console.log(ERROR_COLOR, 'Path length check failed');
26+
console.log('-----------------------------------\n');
27+
if (IS_CI && processExitCode) {
28+
process.exit(processExitCode);
29+
}
30+
} else {
31+
console.log('\n-----------------------------------');
32+
console.log(SUCCESS_COLOR, 'Path length check passed');
33+
console.log('-----------------------------------\n');
34+
}
35+
36+
// Functions
37+
38+
/**
39+
* Recursively check the path length of all files in a directory.
40+
* @param {string} dir - The directory to check for path lengths
41+
* @returns {boolean}
42+
*/
2143
function checkPathLength(dir) {
2244
const files = readdirSync(dir);
2345
let hasError = false;
@@ -32,7 +54,7 @@ function checkPathLength(dir) {
3254
} else if (IS_GITHUB_ACTIONS) {
3355
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.`);
3456
} else {
35-
console.error(`Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${FILE_PATH_COLOR}`, filePath, filePath.length - MAX_PATH_LENGTH);
57+
console.error(FILE_PATH_COLOR, mapFileToSourcePath(filePath), '(exceeds by', filePath.length - MAX_PATH_LENGTH, 'chars)');
3658
}
3759
}
3860

@@ -54,20 +76,5 @@ function checkPathLength(dir) {
5476
* @returns {string}
5577
*/
5678
function mapFileToSourcePath(file) {
57-
return file.replace(PROJECT_DIR, 'src');
58-
}
59-
60-
const hasError = checkPathLength(PROJECT_DIR, MAX_PATH_LENGTH);
61-
62-
if (hasError) {
63-
console.error('\n-----------------------------------');
64-
console.error(ERROR_COLOR, 'Path length check failed');
65-
console.error('-----------------------------------\n');
66-
if (IS_CI && processExitCode) {
67-
process.exit(processExitCode);
68-
}
69-
} else {
70-
console.log('\n-----------------------------------');
71-
console.log(SUCCESS_COLOR, 'Path length check passed');
72-
console.log('-----------------------------------\n');
79+
return file.replace(PROJECT_DIR, 'src').replace('.js', '.ts');
7380
}

0 commit comments

Comments
 (0)