use of com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter in project intellij-plugins by JetBrains.
the class KarmaRunProfileState method getServerOrStart.
@Nullable
public KarmaServer getServerOrStart(@NotNull final Executor executor) throws ExecutionException {
NodeJsInterpreter interpreter = myRunSettings.getInterpreterRef().resolve(myProject);
NodeJsLocalInterpreter localInterpreter = NodeJsLocalInterpreter.castAndValidate(interpreter);
KarmaServerSettings serverSettings = new KarmaServerSettings.Builder().setNodeInterpreter(localInterpreter).setKarmaPackage(myKarmaPackage).setRunSettings(myRunSettings).setWithCoverage(myExecutionType == KarmaExecutionType.COVERAGE).setDebug(myExecutionType == KarmaExecutionType.DEBUG).build();
KarmaServerRegistry registry = KarmaServerRegistry.getInstance(myProject);
KarmaServer server = registry.getServer(serverSettings);
if (server != null && server.getRestarter().isRestartRequired()) {
server.shutdownAsync();
server = null;
}
if (server == null) {
registry.startServer(serverSettings, new CatchingConsumer<KarmaServer, Exception>() {
@Override
public void consume(KarmaServer server) {
RunnerAndConfigurationSettings configuration = myEnvironment.getRunnerAndConfigurationSettings();
if (configuration != null) {
ProgramRunnerUtil.executeConfiguration(myProject, configuration, executor);
}
}
@Override
public void consume(final Exception e) {
LOG.error(e);
showServerStartupError(e);
}
});
}
return server;
}
use of com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter in project intellij-plugins by JetBrains.
the class KarmaExecutionSession method createCommandLine.
@NotNull
private GeneralCommandLine createCommandLine(@NotNull NodeJsLocalInterpreter interpreter, int serverPort, @Nullable KarmaConfig config, @NotNull File clientAppFile) throws ExecutionException {
GeneralCommandLine commandLine = new GeneralCommandLine();
File configFile = new File(myRunSettings.getConfigPath());
// looks like it should work with any working directory
commandLine.setWorkDirectory(configFile.getParentFile());
commandLine.setCharset(CharsetToolkit.UTF8_CHARSET);
commandLine.setExePath(interpreter.getInterpreterSystemDependentPath());
//NodeCommandLineUtil.addNodeOptionsForDebugging(commandLine, Collections.emptyList(), 5858, false, interpreter, true);
commandLine.addParameter(clientAppFile.getAbsolutePath());
commandLine.addParameter("--karmaPackageDir=" + myKarmaServer.getServerSettings().getKarmaPackage().getSystemDependentPath());
commandLine.addParameter("--serverPort=" + serverPort);
if (config != null) {
commandLine.addParameter("--urlRoot=" + config.getUrlRoot());
}
if (isDebug()) {
commandLine.addParameter("--debug=true");
}
if (myRunSettings.getScopeKind() == KarmaScopeKind.TEST_FILE) {
List<String> topNames = findTopLevelSuiteNames(myProject, myRunSettings.getTestFileSystemIndependentPath());
if (topNames.size() > 1) {
throw new ExecutionException("Cannot run test file with several top level suites");
}
topNames = ContainerUtil.map(topNames, s -> s + " ");
commandLine.addParameter("--testName=" + StringUtil.join(topNames, "|"));
} else if (myRunSettings.getScopeKind() == KarmaScopeKind.SUITE || myRunSettings.getScopeKind() == KarmaScopeKind.TEST) {
commandLine.addParameter("--testName=" + StringUtil.join(myRunSettings.getTestNames(), " "));
}
return commandLine;
}
use of com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter in project intellij-plugins by JetBrains.
the class KarmaExecutionSession method createOSProcessHandler.
@NotNull
private OSProcessHandler createOSProcessHandler(@NotNull KarmaServer server, @NotNull File clientAppFile) throws ExecutionException {
NodeJsLocalInterpreter interpreter = myRunSettings.getInterpreterRef().resolveAsLocal(myProject);
GeneralCommandLine commandLine = createCommandLine(interpreter, server.getServerPort(), server.getKarmaConfig(), clientAppFile);
OSProcessHandler processHandler = new KillableColoredProcessHandler(commandLine);
server.getRestarter().onRunnerExecutionStarted(processHandler);
ProcessTerminatedListener.attach(processHandler);
mySmtConsoleView.attachToProcess(processHandler);
return processHandler;
}
use of com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter in project intellij-plugins by JetBrains.
the class KarmaRunConfiguration method getOrInitKarmaPackage.
@NotNull
private NodePackage getOrInitKarmaPackage() {
NodePackage pkg = myRunSettings.getKarmaPackage();
if (pkg == null) {
Project project = getProject();
NodeJsLocalInterpreter interpreter = NodeJsLocalInterpreter.tryCast(myRunSettings.getInterpreterRef().resolve(project));
pkg = NodePackage.findPreferredPackage(project, KarmaUtil.NODE_PACKAGE_NAME, interpreter);
if (!pkg.isEmptyPath() && !KarmaUtil.isPathUnderContentRoots(project, pkg)) {
NodePackage projectKarmaPackage = KarmaProjectSettings.getKarmaPackage(project);
if (projectKarmaPackage.isEmptyPath()) {
KarmaProjectSettings.setKarmaPackage(project, pkg);
}
pkg = new NodePackage("");
}
myRunSettings = myRunSettings.toBuilder().setKarmaPackage(pkg).build();
}
return pkg;
}
Aggregations