Skip to content

Commit

Permalink
improve coding logic
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-sharma7 committed Jul 25, 2023
1 parent 9dd8fe8 commit 5122d63
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ public void runtimeInit(
@BuildStep(onlyIf = IsDevelopment.class)
List<HotDeploymentWatchedFileBuildItem> hotDeploymentWatchedFiles(QuinoaConfig quinoaConfig,
OutputTargetBuildItem outputTarget) {
final List<HotDeploymentWatchedFileBuildItem> watchedFiles = new ArrayList<>(PackageManagerType.values().length);
final List<HotDeploymentWatchedFileBuildItem> watchedFiles = new ArrayList<>(
PackageManagerType.values().length);
final ProjectDirs projectDirs = resolveProjectDirs(quinoaConfig, outputTarget);
if (projectDirs == null) {
// UI dir is misconfigured so just skip watching files
Expand Down Expand Up @@ -263,7 +264,8 @@ private QuinoaDirectoryBuildItem initDefaultConfig(PackageManager packageManager
buildDirectory = detectedFramework.getBuildDirectory();
LOG.infof("%s framework setting build directory: '%s'", framework, buildDirectory);
}
return new QuinoaDirectoryBuildItem(packageManager, detectedFramework.getDevServerCommand(), port, buildDirectory);
return new QuinoaDirectoryBuildItem(packageManager, detectedFramework.getDevServerCommand(), port,
buildDirectory);
}

private HashSet<BuiltResourcesBuildItem.BuiltResource> prepareBuiltResources(
Expand All @@ -277,7 +279,8 @@ private HashSet<BuiltResourcesBuildItem.BuiltResource> prepareBuiltResources(
for (Path file : files) {
final String name = "/" + targetDir.relativize(file).toString().replace('\\', '/');
LOG.infof("Quinoa generated resource: '%s'", name);
generatedResources.produce(new GeneratedResourceBuildItem(META_INF_WEB_UI + name, Files.readAllBytes(file), true));
generatedResources
.produce(new GeneratedResourceBuildItem(META_INF_WEB_UI + name, Files.readAllBytes(file), true));
if (nativeImageResources != null) {
nativeImageResources
.produce(new NativeImageResourceBuildItem(META_INF_WEB_UI + name));
Expand Down Expand Up @@ -337,9 +340,9 @@ static Path findProjectRoot(Path outputDirectory) {
}
if (currentPath.getParent() != null && Files.exists(currentPath.getParent())) {
currentPath = currentPath.getParent();
} else {
return null;
}
return null;

} while (true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public void install(boolean frozenLockfile) {
LOG.infof("Running Quinoa package manager install command: %s", install.commandWithArguments);
if (!exec(install)) {
throw new RuntimeException(
format("Error in Quinoa while running package manager install command: %s", install.commandWithArguments));
format("Error in Quinoa while running package manager install command: %s",
install.commandWithArguments));
}
}

Expand All @@ -59,7 +60,8 @@ public void build(LaunchMode mode) {
LOG.infof("Running Quinoa package manager build command: %s", build.commandWithArguments);
if (!exec(build)) {
throw new RuntimeException(
format("Error in Quinoa while running package manager build command: %s", build.commandWithArguments));
format("Error in Quinoa while running package manager build command: %s",
build.commandWithArguments));
}
}

Expand All @@ -68,7 +70,8 @@ public void test() {
LOG.infof("Running Quinoa package manager test command: %s", test.commandWithArguments);
if (!exec(test)) {
throw new RuntimeException(
format("Error in Quinoa while running package manager test command: %s", test.commandWithArguments));
format("Error in Quinoa while running package manager test command: %s",
test.commandWithArguments));
}
}

Expand Down Expand Up @@ -114,7 +117,8 @@ private static void killDescendants(ProcessHandle process, boolean force) {
});
}

public DevServer dev(String devServerCommand, String devServerHost, int devServerPort, String checkPath, int checkTimeout) {
public DevServer dev(String devServerCommand, String devServerHost, int devServerPort, String checkPath,
int checkTimeout) {
final Command dev = packageManagerCommands.dev(devServerCommand);
LOG.infof("Running Quinoa package manager live coding as a dev service: %s", dev.commandWithArguments);
Process p = process(dev);
Expand Down Expand Up @@ -228,9 +232,8 @@ private boolean exec(Command command) {
private String[] runner(Command command) {
if (isWindows()) {
return new String[] { "cmd.exe", "/c", command.commandWithArguments };
} else {
return new String[] { "sh", "-c", command.commandWithArguments };
}
return new String[] { "sh", "-c", command.commandWithArguments };
}

private static class HandleOutput implements Runnable {
Expand Down
Loading

0 comments on commit 5122d63

Please sign in to comment.