1
0
Fork 0

port startup fix

This commit is contained in:
jsteemann 2018-09-17 10:07:43 +02:00
parent f93b6fd7b8
commit e51359b68e
1 changed files with 22 additions and 0 deletions

View File

@ -215,6 +215,28 @@ void V8DealerFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
ctx->normalizePath(_startupDirectory, "javascript.startup-directory", true);
ctx->normalizePath(_moduleDirectory, "javascript.module-directory", false);
// try to append the current version name to the startup directory,
// so instead of "/path/to/js" we will get "/path/to/js/3.4.0"
std::string const versionAppendix = std::regex_replace(rest::Version::getServerVersion(), std::regex("-.*$"), "");
std::string versionedPath = basics::FileUtils::buildFilename(_startupDirectory, versionAppendix);
LOG_TOPIC(DEBUG, Logger::V8) << "checking for existence of version-specific startup-directory '" << versionedPath << "'";
if (basics::FileUtils::isDirectory(versionedPath)) {
// version-specific js path exists!
_startupDirectory = versionedPath;
}
for (auto& it : _moduleDirectory) {
versionedPath = basics::FileUtils::buildFilename(it, versionAppendix);
LOG_TOPIC(DEBUG, Logger::V8) << "checking for existence of version-specific module-directory '" << versionedPath << "'";
if (basics::FileUtils::isDirectory(versionedPath)) {
// version-specific js path exists!
it = versionedPath;
}
}
// check whether app-path was specified
if (_appPath.empty()) {