Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions scripts/scanTypescript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,27 @@ if [ "${changeDetectionReturnCode}" == "0" ] ; then
else
echo "scanTypescript: Detected change (${changeDetectionReturnCode}). Scanning Typescript source using @jqassistant/ts-lce."

# Note: The npx command will be executed in the source directory using a subshell by putting parentheses around it.
# The subshell is the reason why it isn't needed to change back to the main directory after execution.
# Note: This script must not output anything except for the return code to stdout,
# all output of the scanning needs to be redirected to stderr using ">&2".
# For later troubleshooting, the output is also copied to a dedicated log file using "tee".
# Note: Don't worry about the hardcoded version number. It will be updated by Renovate using a custom Manager.
mkdir -p "./runtime/logs"
( cd "./${SOURCE_DIRECTORY}" && npx --yes @jqassistant/[email protected] --extension React 2>&1 | tee "./../runtime/logs/jqassistant-typescript-scan.log" >&2 || exit )

changeDetectionReturnCode=$( source "${SCRIPTS_DIR}/detectChangedFiles.sh" --hashfile "${changeDetectionHashFilePath}" --paths "./${SOURCE_DIRECTORY}")
fi

source_directories=$( find -L "./${SOURCE_DIRECTORY}" -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -r -I {} echo {} )
total_directories=$(echo "${source_directories}" | wc -l | awk '{print $1}')
processed_directories=0

for directory in ${source_directories}; do
directory_name=$(basename "${directory}");
# Note: The npx command will be executed in the source directory using a subshell by putting parentheses around it.
# The subshell is the reason why it isn't needed to change back to the main directory after execution.
# Note: This script must not output anything except for the return code to stdout,
# all output of the scanning needs to be redirected to stderr using ">&2".
# For later troubleshooting, the output is also copied to a dedicated log file using "tee".
# Note: Don't worry about the hardcoded version number. It will be updated by Renovate using a custom Manager.
# Note: NODE_OPTIONS --max-old-space-size=4096 increases the memory for larger projects to scan
( cd "${directory}" && NODE_OPTIONS="${NODE_OPTIONS} --max-old-space-size=4096" npx --yes @jqassistant/[email protected] --extension React 2>&1 | tee "./../../runtime/logs/jqassistant-typescript-scan-${directory_name}.log" >&2 || exit )
processed_directories=$((processed_directories + 1))
echo "" >&2
echo "scanTypescript: Scanned ${directory_name} (${processed_directories}/${total_directories}) ----------------------" >&2
echo "" >&2
done

changeDetectionReturnCode=$( source "${SCRIPTS_DIR}/detectChangedFiles.sh" --hashfile "${changeDetectionHashFilePath}" --paths "./${SOURCE_DIRECTORY}")
fi