Skip to content

Commit 121a0b5

Browse files
Merge branch 'master' into tsenov/merge-release-in-master
2 parents 443d6b5 + 5fd7913 commit 121a0b5

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

tns-core-modules/module-name-resolver/non-bundle-workflow-compat.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,36 @@ function processFile(file: fs.File) {
5656
}
5757
}
5858

59-
function processFolder(path: string) {
59+
/**
60+
* Processes folder and returns true if folder was not empty.
61+
* @param Folder path
62+
*/
63+
function processFolder(path: string): boolean {
6064
if (cache.has(path)) {
61-
return;
65+
return true;
6266
}
6367
cache.add(path);
6468

6569
if (traceEnabled()) {
6670
traceWrite(`[Compat] Processing folder: ${path}`, traceCategories.ModuleNameResolver);
6771
}
72+
73+
let folderEmpty = true;
6874

6975
if (fs.Folder.exists(path)) {
7076
const folder = fs.Folder.fromPath(path);
7177

7278
folder.eachEntity((file) => {
7379
if (file instanceof fs.File) {
7480
processFile(file);
81+
folderEmpty = false;
7582
}
7683

7784
return true;
7885
});
7986
}
87+
88+
return !folderEmpty;
8089
}
8190

8291
/**
@@ -87,23 +96,25 @@ function processFolder(path: string) {
8796
export function registerModulesFromFileSystem(moduleName: string) {
8897
initialize();
8998

90-
let folderFound = false;
99+
let folderProcessed = false;
100+
let parentFolderProcessed = false;
91101
// moduleName is a folder with package.json
92102
const path = fs.path.join(fs.knownFolders.currentApp().path, moduleName);
93103
if (fs.Folder.exists(path)) {
94-
processFolder(path);
95-
folderFound = true;
104+
folderProcessed = processFolder(path);
96105
}
97106

98107
// moduleName is file - load all files in its parent folder
99108
const parentName = moduleName.substr(0, moduleName.lastIndexOf(fs.path.separator));
100109
const parentFolderPath = fs.path.join(fs.knownFolders.currentApp().path, parentName);
101110
if (fs.Folder.exists(parentFolderPath)) {
102-
processFolder(parentFolderPath);
103-
folderFound = true;
111+
parentFolderProcessed = processFolder(parentFolderPath);
104112
}
105113

106-
if (folderFound) {
114+
// Return only if we processed the actual folder or its parent folder.
115+
// If the parent folder is empty we should still check tns_modules
116+
// as this might be just a name of a plugin (ex. "nativescript-ui-autocomplete")
117+
if (folderProcessed || (parentFolderProcessed && parentName)) {
107118
return;
108119
}
109120

0 commit comments

Comments
 (0)