mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Make knownFolders.currentApp default to __dirname.
In cases where we can't find a `tns_modules` subfolder (webpack, etc), assume the current dir is the app dir.
This commit is contained in:
@@ -442,10 +442,17 @@ export module knownFolders {
|
||||
|
||||
export var currentApp = function (): Folder {
|
||||
if (!_app) {
|
||||
var currentDir = __dirname;
|
||||
var path = currentDir.substring(0, currentDir.indexOf("/tns_modules"));
|
||||
const currentDir = __dirname;
|
||||
const tnsModulesIndex = currentDir.indexOf("/tns_modules");
|
||||
|
||||
// Module not hosted in ~/tns_modules when bundled. Use current dir.
|
||||
let appPath = currentDir;
|
||||
if (tnsModulesIndex !== -1) {
|
||||
// Strip part after tns_modules to obtain app root
|
||||
appPath = currentDir.substring(0, tnsModulesIndex);
|
||||
}
|
||||
_app = new Folder();
|
||||
_app[pathProperty] = path;
|
||||
_app[pathProperty] = appPath;
|
||||
_app[isKnownProperty] = true;
|
||||
}
|
||||
|
||||
@@ -465,4 +472,4 @@ export module path {
|
||||
}
|
||||
|
||||
export var separator = getFileAccess().getPathSeparator();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user