Skip to content

Commit

Permalink
Only export Cordova files if they are available
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Feb 5, 2018
1 parent 1cb151c commit ba29e79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ private JSInjector getJSInjector() {
try {
String coreJS = JSExport.getCoreJS(context);
String pluginJS = JSExport.getPluginJS(plugins.values());
String cordovaJS = ""; // JSExport.getCordovaJS(context);
String cordovaPluginsJS = ""; // JSExport.getCordovaPluginJS(context);
String cordovaPluginsFileJS = ""; // JSExport.getCordovaPluginsFileJS(context);
String cordovaJS = JSExport.getCordovaJS(context);
String cordovaPluginsJS = JSExport.getCordovaPluginJS(context);
String cordovaPluginsFileJS = JSExport.getCordovaPluginsFileJS(context);

return new JSInjector(coreJS, pluginJS, cordovaJS, cordovaPluginsJS, cordovaPluginsFileJS);
} catch(JSExportException ex) {
Expand Down
16 changes: 10 additions & 6 deletions android/capacitor/src/main/java/com/getcapacitor/JSExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,24 @@ private static String getJS(Context context, String fileName) throws IOException
}
}

public static String getCordovaJS(Context context) throws JSExportException {
public static String getCordovaJS(Context context) {
String fileContent = "";
try {
return getJS(context, "public/cordova.js");
fileContent = getJS(context, "public/cordova.js");
} catch(IOException ex) {
throw new JSExportException("Unable to load cordova.js. Capacitor will not function!", ex);
Log.e(Bridge.TAG, "Unable to read public/cordova.js file, Cordova plugins will not work");
}
return fileContent;
}

public static String getCordovaPluginsFileJS(Context context) throws JSExportException {
public static String getCordovaPluginsFileJS(Context context) {
String fileContent = "";
try {
return getJS(context, "public/cordova_plugins.js");
fileContent = getJS(context, "public/cordova_plugins.js");
} catch(IOException ex) {
throw new JSExportException("Unable to load cordova_plugins.js. Capacitor will not function!", ex);
Log.e(Bridge.TAG, "Unable to read public/cordova_plugins.js file, Cordova plugins will not work");
}
return fileContent;
}

public static String getPluginJS(Collection<PluginHandle> plugins) {
Expand Down

0 comments on commit ba29e79

Please sign in to comment.