rearrange the flow a bit
This commit is contained in:
@@ -18,6 +18,28 @@ console.log('\n-----------------------------------');
|
||||
console.log('Results:');
|
||||
console.log('-----------------------------------\n');
|
||||
|
||||
const hasError = checkPathLength(PROJECT_DIR, MAX_PATH_LENGTH);
|
||||
|
||||
if (hasError) {
|
||||
console.log('\n-----------------------------------');
|
||||
console.log(ERROR_COLOR, 'Path length check failed');
|
||||
console.log('-----------------------------------\n');
|
||||
if (IS_CI && processExitCode) {
|
||||
process.exit(processExitCode);
|
||||
}
|
||||
} else {
|
||||
console.log('\n-----------------------------------');
|
||||
console.log(SUCCESS_COLOR, 'Path length check passed');
|
||||
console.log('-----------------------------------\n');
|
||||
}
|
||||
|
||||
// Functions
|
||||
|
||||
/**
|
||||
* Recursively check the path length of all files in a directory.
|
||||
* @param {string} dir - The directory to check for path lengths
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function checkPathLength(dir) {
|
||||
const files = readdirSync(dir);
|
||||
let hasError = false;
|
||||
@@ -32,7 +54,7 @@ function checkPathLength(dir) {
|
||||
} else if (IS_GITHUB_ACTIONS) {
|
||||
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.`);
|
||||
} else {
|
||||
console.error(`Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${FILE_PATH_COLOR}`, filePath, filePath.length - MAX_PATH_LENGTH);
|
||||
console.error(FILE_PATH_COLOR, mapFileToSourcePath(filePath), '(exceeds by', filePath.length - MAX_PATH_LENGTH, 'chars)');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,20 +76,5 @@ function checkPathLength(dir) {
|
||||
* @returns {string}
|
||||
*/
|
||||
function mapFileToSourcePath(file) {
|
||||
return file.replace(PROJECT_DIR, 'src');
|
||||
}
|
||||
|
||||
const hasError = checkPathLength(PROJECT_DIR, MAX_PATH_LENGTH);
|
||||
|
||||
if (hasError) {
|
||||
console.error('\n-----------------------------------');
|
||||
console.error(ERROR_COLOR, 'Path length check failed');
|
||||
console.error('-----------------------------------\n');
|
||||
if (IS_CI && processExitCode) {
|
||||
process.exit(processExitCode);
|
||||
}
|
||||
} else {
|
||||
console.log('\n-----------------------------------');
|
||||
console.log(SUCCESS_COLOR, 'Path length check passed');
|
||||
console.log('-----------------------------------\n');
|
||||
return file.replace(PROJECT_DIR, 'src').replace('.js', '.ts');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user