java-caller
Advanced tools
Comparing version 3.1.2-beta202311191629.0 to 3.1.2
@@ -74,9 +74,11 @@ #! /usr/bin/env node | ||
* @param {string} [runOptions.javaArgs = []] - You can override cwd of spawn called by JavaCaller runner | ||
* @return {Promise<{status:number, stdout:string, stderr:string, childJavaProcess:ChildProcess}>} - Command result (status, stdout, stderr, childJavaProcess) | ||
* @param {string} [runOptions.windowsVerbatimArguments = true] - No quoting or escaping of arguments is done on Windows. Ignored on Unix. This is set to true automatically when shell is specified and is CMD. | ||
* @return {Promise<{status:number, stdout:string, stderr:string, childJavaProcess:ChildProcess}>} - Command result (status, stdout, stderr, childJavaProcess) | ||
*/ | ||
async run(userArguments, runOptions = {}) { | ||
runOptions.detached = runOptions.detached || false; | ||
runOptions.waitForErrorMs = runOptions.waitForErrorMs || 500; | ||
runOptions.cwd = runOptions.cwd || process.cwd(); | ||
runOptions.stdoutEncoding = runOptions.stdoutEncoding || 'utf8'; | ||
runOptions.detached = typeof runOptions.detached === "undefined" ? false : runOptions.detached; | ||
runOptions.waitForErrorMs = typeof runOptions.waitForErrorMs === "undefined" ? 500 : runOptions.waitForErrorMs; | ||
runOptions.cwd = typeof runOptions.cwd === "undefined" ? process.cwd() : runOptions.cwd; | ||
runOptions.stdoutEncoding = typeof runOptions.stdoutEncoding === "undefined" ? "utf8" : runOptions.stdoutEncoding; | ||
runOptions.windowsVerbatimArguments = typeof runOptions.windowsVerbatimArguments === "undefined" ? true : runOptions.windowsVerbatimArguments; | ||
this.commandJavaArgs = (runOptions.javaArgs || []).concat(this.additionalJavaArgs); | ||
@@ -108,3 +110,3 @@ | ||
windowsHide: true, | ||
windowsVerbatimArguments: true, | ||
windowsVerbatimArguments: runOptions.windowsVerbatimArguments, | ||
}; | ||
@@ -151,3 +153,3 @@ if (javaExe.includes(" ")) { | ||
resolve(); | ||
}, runOptions.waitForErrorMs) | ||
}, runOptions.waitForErrorMs), | ||
); | ||
@@ -194,3 +196,3 @@ } else { | ||
// Set first java arguments, then jar || classpath, then jar/class user arguments | ||
buildArguments(classPathStr, userArgs) { | ||
buildArguments(classPathStr, userArgs, windowsVerbatimArguments) { | ||
let javaArgs = []; | ||
@@ -208,5 +210,10 @@ let programArgs = []; | ||
if (this.jar) { | ||
allArgs.push(...["-jar", os.platform() === "win32" ? `"${this.rootPath}/${this.jar}"` : `${this.rootPath}/${this.jar}`]); | ||
allArgs.push( | ||
...[ | ||
"-jar", | ||
os.platform() === "win32" && windowsVerbatimArguments ? `"${this.rootPath}/${this.jar}"` : `${this.rootPath}/${this.jar}`, | ||
], | ||
); | ||
} else { | ||
allArgs.push(...["-cp", os.platform() === "win32" ? `"${classPathStr}"` : classPathStr, this.mainClass]); | ||
allArgs.push(...["-cp", os.platform() === "win32" && windowsVerbatimArguments ? `"${classPathStr}"` : classPathStr, this.mainClass]); | ||
} | ||
@@ -213,0 +220,0 @@ allArgs.push(...programArgs); |
{ | ||
"name": "java-caller", | ||
"version": "3.1.2-beta202311191629.0", | ||
"version": "3.1.2", | ||
"description": "Library to easily call java from node sources. Automatically installs java if not present", | ||
@@ -48,2 +48,3 @@ "main": "./lib/index.js", | ||
"nyc": "^15.1.0", | ||
"prettier": "^3.1.0", | ||
"which": "^4.0.0" | ||
@@ -50,0 +51,0 @@ }, |
@@ -55,3 +55,2 @@ <!-- markdownlint-disable MD033 --> | ||
### JAVA_ARGUMENTS | ||
@@ -61,3 +60,3 @@ | ||
- Java arguments (**-X*** , **-D***). ex: `"-Xms256m"`, `"-Xmx2048m"` | ||
- Java arguments (**-X***, **-D***). ex: `"-Xms256m"`, `"-Xmx2048m"` | ||
- Main class arguments (sent to `public static void main method`). ex: `"--someflag"` , `"--someflagwithvalue myVal"` , `"-c"` | ||
@@ -69,10 +68,11 @@ | ||
| Parameter | Description | Default | Example | | ||
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|-------------------------| | ||
| [detached](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) | If set to true, node will node wait for the java command to be completed.<br/>In that case, `childJavaProcess` property will be returned, but `stdout` and `stderr` may be empty, except if an error is triggered at command execution | `false` | `true` | | ||
| waitForErrorMs | If detached is true, number of milliseconds to wait to detect an error before exiting JavaCaller run | `500` | `2000` | | ||
| [cwd](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) | You can override cwd of spawn called by JavaCaller runner | `process.cwd()` | `some/other/cwd/folder` | | ||
| javaArgs | List of arguments for JVM only, not the JAR or the class | `[]` | `['--add-opens=java.base/java.lang=ALL-UNNAMED']` | | ||
| Parameter | Description | Default | Example | | ||
|-----------|-------------|---------|---------| | ||
| [detached](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) | If set to true, node will node wait for the java command to be completed.<br/>In that case, `childJavaProcess` property will be returned, but `stdout` and `stderr` may be empty, except if an error is triggered at command execution | `false` | `true` | ||
| [stdoutEncoding](https://nodejs.org/api/stream.html#readablesetencodingencoding) | Adds control on spawn process stdout | `utf8` | `ucs2` | | ||
| waitForErrorMs | If detached is true, number of milliseconds to wait to detect an error before exiting JavaCaller run | `500` | `2000` | | ||
| [cwd](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) | You can override cwd of spawn called by JavaCaller runner | `process.cwd()` | `some/other/cwd/folder` | | ||
| javaArgs | List of arguments for JVM only, not the JAR or the class | `[]` | `['--add-opens=java.base/java.lang=ALL-UNNAMED']` | | ||
| [windowsVerbatimArguments](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) | No quoting or escaping of arguments is done on Windows. Ignored on Unix. This is set to true automatically when shell is specified and is CMD. | `true` | `false` | | ||
## Examples | ||
@@ -159,36 +159,6 @@ | ||
Please follow [Contribution instructions](https://github.com/nvuillam/node-java-caller/blob/master/CONTRIBUTING.md) | ||
Please follow [Contribution instructions](CONTRIBUTING.md) | ||
## RELEASE NOTES | ||
### [2.2.3] 2020-09-05 | ||
- Fix Java 8 detection ([#101@npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint/issues/101)) | ||
### [2.2.0] 2020-08-29 | ||
- Fix CLASSPATH on windows in case there are spaces in paths | ||
- Update License to MIT | ||
### [2.1.0] 2020-08-12 | ||
- Allow to use java-caller to build your own CLI embedding java sources | ||
- Example projects using module and CLI | ||
### [2.0.0] 2020-08-11 | ||
- Big refactoring to simplify and enhance performances of code checking/installing java version | ||
- Replace use of deprecated package [node-jre](https://github.com/schreiben/node-jre) by [njre](https://github.com/raftario/njre) | ||
- Compliance with JDK & JRE from 8 to 14 ([AdoptOpenJdk](https://adoptopenjdk.net/) releases) | ||
### [1.1.0] 2020-08-10 | ||
- Return `javaChildProcess` when `detached` is true, so it can be used to be killed later | ||
### [1.0.0] 2020-08-10 | ||
- Initial version | ||
____ | ||
See complete [CHANGELOG](https://github.com/nvuillam/node-java-caller/blob/master/CHANGELOG.md) | ||
See complete [CHANGELOG](CHANGELOG.md) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
421
0
33720
6
161