Skip to content

Commit 2f80959

Browse files
committed
CDS extractor index-files.sh compile to stdout
Attempt to resolve unit test failures for PR #170 of the `advanced-security/codeql-sap-js` repo. Updates the (soon to be replaced) shell-based version of the CDS extractor as an attempted workaround for a change in cds compiler behavior when the `-o` or `--dest` options are set for the `cds compile` CLI command. Forces the cds compmiler to output to the desired .cds.json file path via stdout.
1 parent ba371e1 commit 2f80959

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

extractors/cds/tools/index-files.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ echo "Processing CDS files to JSON"
5151
# Run the cds compile command on each file in the response file, outputting the compiled JSON to a file with
5252
# the same name
5353
while IFS= read -r cds_file; do
54-
echo "Processing CDS file $cds_file to:"
55-
if ! $cds_command compile "$cds_file" -2 json -o "$cds_file.json" --locations 2> "$cds_file.err"; then
54+
echo "Processing CDS file $cds_file to: $cds_file.json"
55+
# Avoid using the `-o` (or `--dest`) option as it sends output to a new directory, where we want to
56+
# output to a file in the same directory as the input file but with a .json extension.
57+
if ! $cds_command compile "$cds_file" -2 json --locations > "$cds_file.json" 2> "$cds_file.err"
58+
then
5659
stderr_truncated=`grep "^\[ERROR\]" "$cds_file.err" | tail -n 4`
5760
error_message=$'Could not compile the file '"$cds_file"$'.\nReported error(s):\n```\n'"$stderr_truncated"$'\n```'
5861
echo "$error_message"

0 commit comments

Comments
 (0)