|
|
@@ -2,6 +2,8 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
import java.io.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
public class GenCodeTest {
|
|
|
@Test
|
|
|
@@ -20,8 +22,8 @@ public class GenCodeTest {
|
|
|
|
|
|
int insertLocation = routerJs.indexOf("/**INSERT_LOCATION**/");
|
|
|
if (insertLocation > -1) {
|
|
|
- String routeName = StringUtils.capitalize(className);
|
|
|
- String routePath = StringUtils.uncapitalize(className);
|
|
|
+ String routeName = StringUtils.capitalize(className);
|
|
|
+ String routePath = StringUtils.uncapitalize(className);
|
|
|
String route = "{\n path: '/"
|
|
|
+ routePath
|
|
|
+ "',\n name: '"
|
|
|
@@ -46,4 +48,29 @@ public class GenCodeTest {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testUpdateRouter() {
|
|
|
+ try {
|
|
|
+ File file = new File("/Users/drew/Projects/Java/awesomeAdmin/src/main/vue/src/router", "index.js");
|
|
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
|
|
|
+ StringBuilder routerJs = new StringBuilder();
|
|
|
+ String line = null;
|
|
|
+ while ((line = reader.readLine()) != null) {
|
|
|
+ routerJs.append(line).append("\n");
|
|
|
+ }
|
|
|
+ reader.close();
|
|
|
+
|
|
|
+// Pattern pattern = Pattern.compile("\\{[ \\n]*path:[ \\n]*'/404',[ \\n]*name:[ \\n]*'404',[ \\n]*component:[ \\n]*\\([ \\n]*\\)[ \\n]*=>[ \\n]*import\\('\\.\\./pages/404'\\)[ \\n]*}");
|
|
|
+ Pattern pattern = Pattern.compile("'/404");
|
|
|
+ Matcher matcher = pattern.matcher(routerJs.toString());
|
|
|
+ if (matcher.find()) {
|
|
|
+ System.out.println(">>>" + matcher.start());
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|