java-caller 2.5.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,7 +50,7 @@ const {status, stdout, stderr} = java.run(JAVA_ARGUMENTS,JAVA_CALLER_RUN_OPTIONS
50
50
  | maximumJavaVersion | Maximum java version to be used to call java command.<br/> If the java version found on machine is upper, java-caller will try to install and use the appropriate one <br/> Can be equal to minimumJavaVersion | | `10` |
51
51
  | javaType | jre or jdk (if not defined and installation is required, jre will be installed) | | `"jre"` |
52
52
  | additionalJavaArgs | Additional parameters for JVM that will be added in every JavaCaller instance runs | | `["-Xms256m","-Xmx2048m"]` |
53
- | javaExecutable | You can force to use a defined java executable, instead of letting java-caller find/install one | | `"/home/some-java-version/bin/java.exe"` |
53
+ | javaExecutable | You can force to use a defined java executable, instead of letting java-caller find/install one. Can also be defined with env var `JAVA_CALLER_JAVA_EXECUTABLE` | | `"/home/some-java-version/bin/java.exe"` |
54
54
 
55
55
 
56
56
  ### JAVA_ARGUMENTS
@@ -56,7 +56,7 @@ class JavaCaller {
56
56
  this.javaType = opts.javaType || this.javaType;
57
57
  this.rootPath = opts.rootPath || this.rootPath;
58
58
  this.javaCallerSupportDir = `${os.homedir() + path.sep}.java-caller`;
59
- this.javaExecutable = opts.javaExecutable || this.javaExecutable;
59
+ this.javaExecutable = opts.javaExecutable || process.env.JAVA_CALLER_JAVA_EXECUTABLE || this.javaExecutable;
60
60
  this.additionalJavaArgs = opts.additionalJavaArgs || this.additionalJavaArgs;
61
61
  this.output = opts.output || this.output;
62
62
  }
@@ -66,6 +66,7 @@ class JavaCaller {
66
66
  * @param {string[]} [userArguments] - Java command line arguments
67
67
  * @param {object} [runOptions] - Run options
68
68
  * @param {boolean} [runOptions.detached = false] - If set to true, node will node wait for the java command to be completed. In that case, childJavaProcess property will be returned, but stdout and stderr may be empty
69
+ * @param {string} [runOptions.stdoutEncoding = 'utf8'] - Adds control on spawn process stdout
69
70
  * @param {number} [runOptions.waitForErrorMs = 500] - If detached is true, number of milliseconds to wait to detect an error before exiting JavaCaller run
70
71
  * @param {string} [runOptions.cwd = .] - You can override cwd of spawn called by JavaCaller runner
71
72
  * @param {string} [runOptions.javaArgs = []] - You can override cwd of spawn called by JavaCaller runner
@@ -75,13 +76,14 @@ class JavaCaller {
75
76
  runOptions.detached = runOptions.detached || false;
76
77
  runOptions.waitForErrorMs = runOptions.waitForErrorMs || 500;
77
78
  runOptions.cwd = runOptions.cwd || process.cwd();
79
+ runOptions.stdoutEncoding = runOptions.stdoutEncoding || 'utf8';
78
80
  this.commandJavaArgs = (runOptions.javaArgs || []).concat(this.additionalJavaArgs);
79
81
 
80
82
  let javaExe = this.javaExecutable;
81
83
  if (javaExe.toLowerCase().includes(".exe") && !javaExe.includes(`'`)) {
82
84
  // Java executable has been overridden by caller : use it
83
85
  javaExe = `"${path.resolve(javaExe)}"`;
84
- } else {
86
+ } else if (javaExe === "java") {
85
87
  // Check if matching java version is present, install and update PATH if it is not
86
88
  await this.manageJavaInstall();
87
89
  }
@@ -110,6 +112,7 @@ class JavaCaller {
110
112
 
111
113
  // Gather stdout and stderr if they must be returned
112
114
  if (spawnOptions.stdio === "pipe") {
115
+ child.stdout.setEncoding(`${runOptions.stdoutEncoding}`);
113
116
  child.stdout.on("data", (data) => {
114
117
  stdout += data;
115
118
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "java-caller",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "description": "Library to easily call java from node sources. Automatically installs java if not present",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -35,16 +35,16 @@
35
35
  },
36
36
  "homepage": "https://github.com/nvuillam/node-java-caller#readme",
37
37
  "dependencies": {
38
- "debug": "^4.1.1",
39
- "fs-extra": "^9.0.1",
40
- "njre": "^0.2.0"
38
+ "debug": "^4.3.4",
39
+ "fs-extra": "^10.1.0",
40
+ "njre": "^0.3.0"
41
41
  },
42
42
  "devDependencies": {
43
- "babel-eslint": "^10.1.0",
44
- "eslint": "^7.6.0",
45
- "mocha": "^8.1.1",
43
+ "@babel/eslint-parser": "^7.19.1",
44
+ "eslint": "^8.27.0",
45
+ "mocha": "^10.1.0",
46
46
  "nyc": "^15.1.0",
47
- "which": "^2.0.2"
47
+ "which": "^3.0.0"
48
48
  },
49
49
  "engines": {
50
50
  "node": ">=12.0.0"