Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/main/java/com/eclipsesource/v8/NodeJS.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,20 @@ public class NodeJS {
* been compiled for your platform.
*/
public static NodeJS createNodeJS() {
return createNodeJS(null);
return createNodeJS(null, null);
}

/**
* Creates a NodeJS runtime and executes a JS Script
*
* @param file The JavaScript to execute or null for no script.
* @return The NodeJS runtime.
*
* May throw an UnsupportedOperationException if node.js integration has not
* been compiled for your platform.
*/
public static NodeJS createNodeJS(final File file){
return createNodeJS(file, null);
}

/**
Expand Down Expand Up @@ -75,13 +88,14 @@ public String getNodeVersion() {
* Creates a NodeJS runtime and executes a JS Script
*
* @param file The JavaScript to execute or null for no script.
* @param tempDirectory The name of the directory to extract the native
* @return The NodeJS runtime.
*
* May throw an UnsupportedOperationException if node.js integration has not
* been compiled for your platform.
*/
public static NodeJS createNodeJS(final File file) {
V8 v8 = V8.createV8Runtime(GLOBAL);
public static NodeJS createNodeJS(final File file, final String tempDirectory) {
V8 v8 = V8.createV8Runtime(GLOBAL, tempDirectory);
final NodeJS node = new NodeJS(v8);
v8.registerJavaMethod(new JavaVoidCallback() {

Expand Down