Skip to content

Commit dca208d

Browse files
committed
shell - chrooting on srv/ sub-directory when 'app run' command is launched from a directory not containing a md.restx.json file.
This fixes #188
1 parent 6772f7e commit dca208d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

restx-core-shell/src/main/java/restx/core/shell/AppShellCommand.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,28 @@ public void run(final RestxShell shell) throws Exception {
611611
shell.cd(standardCachedAppPath(appNameArg.get()));
612612
}
613613

614+
if(!ModuleDescriptorType.RESTX.resolveDescriptorFile(shell.currentLocation()).exists()) {
615+
616+
Path srvDir = shell.currentLocation().resolve("srv");
617+
if(srvDir.toFile().exists()) {
618+
shell.cd(srvDir);
619+
if(!ModuleDescriptorType.RESTX.resolveDescriptorFile(shell.currentLocation()).exists()) {
620+
shell.println(String.format("Cannot find %s in both %s and %s",
621+
ModuleDescriptorType.RESTX.getDescriptorFileName(),
622+
shell.currentLocation().getParent().toAbsolutePath(),
623+
shell.currentLocation().toAbsolutePath()));
624+
shell.println("=> Cannot run application");
625+
return;
626+
}
627+
} else {
628+
shell.println(String.format("Cannot find %s in %s",
629+
ModuleDescriptorType.RESTX.getDescriptorFileName(),
630+
shell.currentLocation().toAbsolutePath()));
631+
shell.println("=> Cannot run application");
632+
return;
633+
}
634+
}
635+
614636
boolean sourcesAvailable = Apps.with(shell.getFactory().getComponent(AppSettings.class)).sourcesAvailableIn(shell.currentLocation());
615637

616638
String appClassName;

0 commit comments

Comments
 (0)