use of com.intellij.javascript.karma.server.KarmaServerRegistry 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;
}
Aggregations