modules/jooby-assets-nodejs/src/main/java/org/jooby/assets/Nodejs.java
public void exec(final String library, final Throwing.Consumer<V8> callback) throws Throwable {
    Path basedir = deploy(library);
    List<String> candidates = Arrays.asList(
        basedir.getFileName().toString() + ".js",
        "main.js",
        "index.js");

    Path main = candidates.stream()
        .map(basedir::resolve)
        .filter(Files::exists)
        .findFirst()
        .orElseThrow(() -> new FileNotFoundException(candidates.toString()));

    callback.accept(node.getRuntime());

    node.exec(main.toFile());

    while (node.isRunning()) {
      node.handleMessage();
    }
  }
public void exec(final String library, final Throwing.Consumer<V8> callback) throws Throwable {
    Path basedir = deploy(library);
    List<String> candidates = Arrays.asList(
        basedir.getFileName().toString() + ".js",
        "main.js",
        "index.js");

    Path main = candidates.stream()
        .map(basedir::resolve)
        .filter(Files::exists)
        .findFirst()
        .orElseThrow(() -> new FileNotFoundException(candidates.toString()));

    callback.accept(node.getRuntime());

    node.exec(main.toFile());

    while (node.isRunning()) {
      node.handleMessage();
    }
  }
public void exec ( final String library , final Throwing . Consumer < V8 > callback ) throws Throwable { Path basedir = deploy ( library ) ; List < String > candidates = Arrays . asList ( basedir . getFileName ( ) . toString ( ) + ".js" , "main.js" , "index.js" ) ; Path main = candidates . stream ( ) . map ( basedir :: resolve ) . filter ( Files :: exists ) . findFirst ( ) . orElseThrow ( ( ) -> new FileNotFoundException ( candidates . toString ( ) ) ) ; callback . accept ( node . getRuntime ( ) ) ; node . exec ( main . toFile ( ) ) ; while ( node . isRunning ( ) ) { node . handleMessage ( ) ; } }
Unpack and execute a nodejs library. Once unpack this method will execute one of these scripts
in the following order: 1) [library].js; 2) main.js; 3) index.js.

The first file found will be executed.

@param library Library to unpack and execute this library.
@throws Throwable If something goes wrong.
Unpack and execute a nodejs library . Once unpack this method will execute one of these scripts in the following order : 1 ) [ library ] . js ; 2 ) main . js ; 3 ) index . js .