Class NpmWrapper


  • public final class NpmWrapper
    extends java.lang.Object
    Utility class used to invoke the npm executable.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int executeCommand​(de.carne.gradle.plugin.java.util.ExecOut out, @Nullable java.lang.String... args)  
      int executeNpm​(java.io.File logFile, @Nullable java.lang.String... arguments)
      Executes npm using the given arguments.
      static NpmWrapper getInstance​(java.io.File directory, java.lang.String command)
      Gets a NpmWrapper instance for the given parameters.
      java.lang.String npmVersion()
      Gets the wrapped npm version.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static NpmWrapper getInstance​(java.io.File directory,
                                             java.lang.String command)
                                      throws java.io.IOException,
                                             java.lang.InterruptedException
        Gets a NpmWrapper instance for the given parameters.
        Parameters:
        directory - the directory where to run npm.
        command - the actual npm command to use.
        Returns:
        the created NpmWrapper instance.
        Throws:
        java.io.IOException - if an I/O error occurs while probing the npm command.
        java.lang.InterruptedException - if the thread is interrupted while probing the npm command.
      • npmVersion

        public java.lang.String npmVersion()
        Gets the wrapped npm version.
        Returns:
        the wrapped npm version.
      • executeNpm

        public int executeNpm​(java.io.File logFile,
                              @Nullable java.lang.String... arguments)
                       throws java.io.IOException,
                              java.lang.InterruptedException
        Executes npm using the given arguments.
        Parameters:
        logFile - the File to log the command output into.
        arguments - the npm arguments to use.
        Returns:
        the command exit status.
        Throws:
        java.io.IOException - if an I/O error occurs while executing the npm command.
        java.lang.InterruptedException - if the thread is interrupted while executing the npm command.
      • executeCommand

        protected int executeCommand​(de.carne.gradle.plugin.java.util.ExecOut out,
                                     @Nullable java.lang.String... args)
                              throws java.io.IOException,
                                     java.lang.InterruptedException
        Throws:
        java.io.IOException
        java.lang.InterruptedException