Copilot commented on code in PR #416:
URL: https://github.com/apache/maven-wrapper/pull/416#discussion_r3124403832


##########
maven-wrapper-distribution/src/resources/only-mvnw.cmd:
##########
@@ -89,10 +89,11 @@ if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
 }
 
 $MAVEN_WRAPPER_DISTS = $null
-if ((Get-Item -Path $MAVEN_M2_PATH -Force).Target[0] -eq $null) {
-  $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
+$m2Item = Get-Item -Path $MAVEN_M2_PATH -Force
+if ($m2Item.PSObject.Properties['Target'] -ne $null -and $m2Item.Target -ne 
$null) {

Review Comment:
   The new symlink detection condition will mis-handle the common non-symlink 
case where `Get-Item ... .Target` is an empty collection (not `$null`). In that 
scenario `$m2Item.Target -ne $null` is true, but `$m2Item.Target[0]` is 
`$null`, causing `$MAVEN_WRAPPER_DISTS` to become just `"/wrapper/dists"` 
(relative path) instead of using `$MAVEN_M2_PATH`. Update the condition to also 
require a non-null first target (or a non-empty Target collection) before using 
`Target[0]`; otherwise fall back to `$MAVEN_M2_PATH/wrapper/dists`.
   ```suggestion
   if ($m2Item.PSObject.Properties['Target'] -ne $null -and $m2Item.Target -ne 
$null -and $m2Item.Target[0] -ne $null) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to