Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

java-caller

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

java-caller - npm Package Compare versions

Comparing version 2.1.0-beta.2 to 2.1.0

5

CHANGELOG.md
# Changelog
## [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

@@ -4,0 +9,0 @@

17

lib/cli.js

@@ -11,6 +11,5 @@ #! /usr/bin/env node

constructor(configFile) {
configFile = configFile || "./java-caller-config.json";
configFile = fse.existsSync(configFile) ? configFile : path.resolve(`${__dirname}/${configFile}`);
// Use JSON file
constructor(baseDir) {
// Use user-defined JSON file to read configuration
const configFile = path.resolve(`${baseDir}/java-caller-config.json`);
const options = fse.readJSONSync(configFile);

@@ -22,3 +21,3 @@ // Default output is console with CLI

if (options.rootPath == null) {
options.rootPath = __dirname;
options.rootPath = baseDir;
}

@@ -28,7 +27,7 @@ this.javaCallerOptions = options;

async process(processArgv, runOptions = {}) {
async process() {
const java = new JavaCaller(this.javaCallerOptions);
const args = [...processArgv];
args.splice(0, 3);
const { status } = await java.run(args, runOptions);
const args = [...process.argv];
args.splice(0, 2);
const { status } = await java.run(args);
process.exitCode = status;

@@ -35,0 +34,0 @@ }

@@ -94,36 +94,30 @@ #! /usr/bin/env node

debug(`Java command: ${javaExe} ${javaArgs.join(" ")}`);
child = spawn(javaExe, javaArgs, {
const spawnOptions = {
detached: runOptions.detached,
cwd: javaExe === "java" ? runOptions.cwd : undefined,
env: Object.assign({}, process.env),
stdio: runOptions.detached ? "ignore" : "pipe",
stdio: this.output === "console" ? "inherit" : runOptions.detached ? "ignore" : "pipe",
windowsHide: true,
windowsVerbatimArguments: true
});
// Detach from main process in case detached === true
if (runOptions.detached) {
child.unref();
} else {
// Gather stdout and stderr if not detached sub process
};
child = spawn(javaExe, javaArgs, spawnOptions);
// Gather stdout and stderr if they must be returned
if (spawnOptions.stdio === "pipe") {
child.stdout.on("data", data => {
if (this.output === "console") {
console.log(data);
}
stdout += data;
});
child.stderr.on("data", data => {
if (this.output === "console") {
console.error(data);
}
stderr += data;
});
}
// Catch error
child.on("error", data => {
this.status = 666;
if (this.output === "console") {
console.error(data);
}
stderr += "Java spawn error: " + data;
resolve();
});
// Catch status code
child.on("close", code => {

@@ -133,2 +127,7 @@ this.status = code;

});
// Detach from main process in case detached === true
if (runOptions.detached) {
child.unref();
}
});

@@ -158,3 +157,3 @@

// Reset PATH & JAVA_HOME
// Restore previous values of PATH & JAVA_HOME
process.env["PATH"] = this.prevPath || process.env["PATH"];

@@ -161,0 +160,0 @@ process.env["JAVA_HOME"] = this.prevJavaHome || process.env["JAVA_HOME"];

{
"name": "java-caller",
"version": "2.1.0-beta.2",
"version": "2.1.0",
"description": "Library to easily call java from node sources. Automatically installs java if not present",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -20,2 +20,7 @@ <!-- markdownlint-disable MD033 -->

There are two ways to use java-caller:
- **module**: Manually call JavaCaller in your custom JS/TS code ([example project](https://github.com/nvuillam/node-java-caller/tree/master/examples/module_app))
- **CLI**: Just define a java-caller-config.json and you can deliver your java executables as your own NPM packages ! ([example project](https://github.com/nvuillam/node-java-caller/tree/master/examples/cli_app), which can be used as starter kit)
## Installation

@@ -141,2 +146,7 @@

### [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

@@ -143,0 +153,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc