public class ProcessUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
NODE_COMMAND
The node command name (can be full path in some environments).
|
static String |
NODE_MINIMUM_VERSION |
static String |
NPM_COMMAND
The npm command name (can be full path in some environments).
|
static File |
NPM_DIR
A static field that stores the JSweet npm directory.
|
static File |
USER_HOME_DIR
A static field that stores the user home directory.
|
| Constructor and Description |
|---|
ProcessUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addExtraPath(String extraPath) |
static String |
findGlobalExecutable(String fileName,
String packageName) |
static String |
getGlobalNpmPackageExecutablePath(String command)
Gets the full path of a global package's JS main file installed with npm.
|
static String |
getGlobalNpmPackageNodeMainFilePath(String nodeModule,
String mainFileName)
Gets the full path of a global package's (system) command installed with npm.
|
static String |
getGlobalNpmPackagePath(String packageName)
Gets the full path of a global package installed with npm.
|
static void |
initNode()
Initializes the node command paths (OS-specific initializations).
|
static void |
installNodePackage(String nodePackageName,
String version,
boolean global)
Installs a
node |
static boolean |
isInstalledWithNpm(String command)
Tells if this node command is installed.
|
static boolean |
isNodePackageInstalled(String nodePackageName)
Checks if a node package has been installed locally.
|
static boolean |
isVersionHighEnough(String currentVersion,
String minimumVersion) |
static boolean |
isWindows() |
static Process |
runAsyncCommand(String command,
Consumer<String> stdoutConsumer,
Consumer<Process> endConsumer,
Runnable errorHandler,
String... args)
Runs the given command in an asynchronous manner.
|
static Process |
runCommand(String command,
Consumer<String> stdoutConsumer,
Runnable errorHandler,
String... args)
Runs the given command.
|
static Process |
runCommand(String command,
File directory,
boolean async,
Consumer<String> stdoutConsumer,
Consumer<Process> endConsumer,
Runnable errorHandler,
String... args)
Runs the given command.
|
static void |
uninstallNodePackage(String nodePackageName,
boolean global)
Uninstalls a
node |
public static final String NODE_MINIMUM_VERSION
public static File USER_HOME_DIR
public static File NPM_DIR
public static String NODE_COMMAND
public static String NPM_COMMAND
public static void initNode()
public static void addExtraPath(String extraPath)
public static String getGlobalNpmPackageNodeMainFilePath(String nodeModule, String mainFileName)
public static String getGlobalNpmPackageExecutablePath(String command)
public static String getGlobalNpmPackagePath(String packageName)
public static boolean isInstalledWithNpm(String command)
public static Process runCommand(String command, Consumer<String> stdoutConsumer, Runnable errorHandler, String... args)
command - the command namestdoutConsumer - consumes the standard output stream as lines of characterserrorHandler - upcalled when the command does not terminate successfullyargs - the command-line argumentspublic static Process runAsyncCommand(String command, Consumer<String> stdoutConsumer, Consumer<Process> endConsumer, Runnable errorHandler, String... args)
command - the command namestdoutConsumer - consumes the standard output stream as lines of charactersendConsumer - called when the process actually endserrorHandler - upcalled when the command does not terminate successfullyargs - the command-line argumentspublic static Process runCommand(String command, File directory, boolean async, Consumer<String> stdoutConsumer, Consumer<Process> endConsumer, Runnable errorHandler, String... args)
command - the command namedirectory - the working directory of the created processasync - tells if the command should be run asynchronously (in a separate
thread)stdoutConsumer - consumes the standard output stream as lines of charactersendConsumer - called when the process actually endserrorHandler - upcalled when the command does not terminate successfullyargs - the command-line argumentsasync is true)public static boolean isWindows()
public static void installNodePackage(String nodePackageName, String version, boolean global)
node package with npm (assumes that
node is installed).nodePackageName - the package nameglobal - true for adding the -g optionpublic static boolean isNodePackageInstalled(String nodePackageName)
nodePackageName - the node module to be testedpublic static void uninstallNodePackage(String nodePackageName, boolean global)
node package with npm (assumes that
node is installed).nodePackageName - the package nameglobal - true for adding the -g optionpublic static boolean isVersionHighEnough(String currentVersion, String minimumVersion)