Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/src/com/tns/NativeScriptApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public void onCreate() {
}

Platform.init(this);
Platform.run(Platform.DefaultApplicationModuleName);
Platform.run();

onCreateInternal();
}
Expand Down
8 changes: 3 additions & 5 deletions src/src/com/tns/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ public class Platform

private static ArrayList<Constructor<?>> ctorCache = new ArrayList<Constructor<?>>();

public final static String DefaultApplicationModuleName = "./bootstrap";

private static JsDebugger jsDebugger;

public static boolean IsLogEnabled = BuildConfig.DEBUG;
Expand Down Expand Up @@ -187,10 +185,10 @@ static void setExtractPolicy(ExtractPolicy policy)
extractPolicy = policy;
}

public static void run(String appFileName)
public static void run()
{
String appContent = Require.getAppContent(appFileName);
runNativeScript(appFileName, appContent);
String[] bootstrapInfo = Require.bootstrapApp();
runNativeScript(bootstrapInfo[0], bootstrapInfo[1]);
}

private static int cacheConstructor(String name, String className, Object[] args, String[] methodOverrides) throws ClassNotFoundException, IOException
Expand Down
25 changes: 22 additions & 3 deletions src/src/com/tns/Require.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,29 @@ public static String getApplicationFilesPath()
return ApplicationFilesPath;
}

public static String getAppContent(String appFileName)
public static String[] bootstrapApp()
{
File bootstrapFile = findModuleFile(appFileName, "");
return getModuleContent(bootstrapFile.getPath());
// Bootstrap logic flows like:
// 1. Check for package.json -> `main` field
// 2. Check for index.js
// 3. Check for bootstrap.js

File bootstrapFile = findModuleFile("./", "");
if(!bootstrapFile.exists())
{
bootstrapFile = findModuleFile("./bootstrap", "");
}

if(!bootstrapFile.exists())
{
Platform.APP_FAIL("Application entry point file not found. Please specify either package.json with main field, index.js or bootstrap.js!");
}

String[] bootstrapInfo = new String[2];
bootstrapInfo[0] = bootstrapFile.getName();
bootstrapInfo[1] = getModuleContent(bootstrapFile.getPath());

return bootstrapInfo;
}

public static String getModuleContent(String modulePath)
Expand Down