Skip to content

Handle Absolute JAR Path #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 11, 2025
Merged

Conversation

BrendanC23
Copy link
Contributor

This PR enables an absolute path to be passed as the jar parameter. It resolves #104. A new test (that previously would have failed) has been added.

Now, this code works:

const java = new JavaCaller({
    jar: "F:\\my-path\\file.jar",
});

Readiness Checklist

Author/Contributor

  • Add entry to the CHANGELOG.md listing the change and linking to the corresponding issue (if appropriate)
  • If documentation is needed for this change, has that been included in this pull request

Reviewing Maintainer

  • Label as breaking if this is a large fundamental change
  • Label as either automation, bug, documentation, enhancement, infrastructure, or performance

This commit fixes instances where the `jar` parameter is an absolute
path to the JAR file. Previously, the path for

```js
const java = new JavaCaller({
    jar: "F:\\my-path\\file.jar",
});
```

would become `./F:\\my-path\\file.jar`. Now, it is kept as-is, allowing
absolute paths to be provided.
This commit fixes instances where the `jar` parameter is an absolute
path to the JAR file. Previously, the path for

```js
const java = new JavaCaller({
    jar: "F:\\my-path\\file.jar",
});
```

would become `./F:\\my-path\\file.jar`. Now, it is kept as-is, allowing
absolute paths to be provided.
@nvuillam
Copy link
Owner

@BrendanC23 the test class is failing, please can you have a look ?

image

nvuillam and others added 2 commits February 23, 2025 10:17
This commit fixes the handling of absolute paths, switching from
`path.join()` to `path.isAbsolute()` to handle differing behavior for
different platforms.

`path.join()` works differently for Windows paths and Linux paths.
`path.join(".", "C:\\") === "C:\\"`
`path.join(".", "/home/test") === "home/test"`

The latter is missing a leading `/` and thus is no longer an
absolute path.

As described in [this issue](GHSA-37v4-cwgp-x353),
there was a NodeJS [security vulnerability](https://nodejs.org/en/blog/vulnerability/january-2025-security-releases)
that caused the behavior of `path.join()` to be changed. Newer versions
of Node will return a relative path in these instances, so
`path.join(".", "C:\\") === ".\\C:\\"`.
@BrendanC23
Copy link
Contributor Author

@nvuillam I made some changes to the PR. There is one test that is failing due to a timeout.

image

@codecov-commenter
Copy link

codecov-commenter commented May 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.95%. Comparing base (fb429b7) to head (64d99a3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #106      +/-   ##
==========================================
+ Coverage   89.91%   89.95%   +0.04%     
==========================================
  Files           3        3              
  Lines         228      229       +1     
==========================================
+ Hits          205      206       +1     
  Misses         23       23              
Flag Coverage Δ
unittests 89.95% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Owner

@nvuillam nvuillam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrendanC23 thanks for the PR and sorry for the delay :)

@nvuillam nvuillam merged commit 0009dbc into nvuillam:main May 11, 2025
30 checks passed
@BrendanC23 BrendanC23 deleted the absolute-jar-path branch May 11, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Absolute jar path
3 participants