Skip to content

Commit

Permalink
Fix Config Path to work correctly with Windows (#1865)
Browse files Browse the repository at this point in the history
  • Loading branch information
rishi-aga authored Feb 24, 2021
1 parent 8dcbfc5 commit 6a95919
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@
*/
package com.yahoo.elide.modelconfig;

import java.io.File;
/**
* Dynamic Config enum.
*/
public enum Config {

TABLE("table",
"models" + File.separator + "tables" + File.separator,
File.separator + "elideTableSchema.json"),
"models/tables/",
"/elideTableSchema.json"),

SECURITY("security",
"models" + File.separator + "security.hjson",
File.separator + "elideSecuritySchema.json"),
"models/security.hjson",
"/elideSecuritySchema.json"),

MODELVARIABLE("variable",
"models" + File.separator + "variables.hjson",
File.separator + "elideVariableSchema.json"),
"models/variables.hjson",
"/elideVariableSchema.json"),

DBVARIABLE("variable",
"db" + File.separator + "variables.hjson",
File.separator + "elideVariableSchema.json"),
"db/variables.hjson",
"/elideVariableSchema.json"),

SQLDBConfig("sqldbconfig",
"db" + File.separator + "sql" + File.separator,
File.separator + "elideDBConfigSchema.json");
"db/sql/",
"/elideDBConfigSchema.json");

private final String configType;
private final String configPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.hjson.ParseException;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -43,11 +42,10 @@ public static boolean isNullOrEmpty(String input) {
* @return formatted file path.
*/
public static String formatFilePath(String basePath) {
if (isNullOrEmpty(basePath) || basePath.endsWith(File.separator)) {
return basePath;
} else {
return basePath += File.separator;
if (!(isNullOrEmpty(basePath) || basePath.endsWith("/"))) {
basePath += "/";
}
return basePath;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@ private static void printHelp(Options options) {
* @return Path to model dir
*/
public static String formatClassPath(String filePath) {
if (filePath.indexOf(RESOURCES + File.separator) > -1) {
return filePath.substring(filePath.indexOf(RESOURCES + File.separator) + RESOURCES_LENGTH + 1);
if (filePath.indexOf(RESOURCES + "/") > -1) {
return filePath.substring(filePath.indexOf(RESOURCES + "/") + RESOURCES_LENGTH + 1);
} else if (filePath.indexOf(RESOURCES) > -1) {
return filePath.substring(filePath.indexOf(RESOURCES) + RESOURCES_LENGTH);
}
Expand Down

0 comments on commit 6a95919

Please sign in to comment.