| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,27 +56,36 @@ function processFile(file: fs.File) { | |||
| 56 | 56 | } | |
| 57 | 57 | } | |
| 58 | 58 | ||
| 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 { | ||
| 60 | 64 | if (cache.has(path)) { | |
| 61 | - return; | ||
| 65 | + return true; | ||
| 62 | 66 | } | |
| 63 | 67 | cache.add(path); | |
| 64 | 68 | ||
| 65 | 69 | if (traceEnabled()) { | |
| 66 | 70 | traceWrite(`[Compat] Processing folder: ${path}`, traceCategories.ModuleNameResolver); | |
| 67 | 71 | } | |
| 72 | + | ||
| 73 | + let folderEmpty = true; | ||
| 68 | 74 | ||
| 69 | 75 | if (fs.Folder.exists(path)) { | |
| 70 | 76 | const folder = fs.Folder.fromPath(path); | |
| 71 | 77 | ||
| 72 | 78 | folder.eachEntity((file) => { | |
| 73 | 79 | if (file instanceof fs.File) { | |
| 74 | 80 | processFile(file); | |
| 81 | + folderEmpty = false; | ||
| 75 | 82 | } | |
| 76 | 83 | ||
| 77 | 84 | return true; | |
| 78 | 85 | }); | |
| 79 | 86 | } | |
| 87 | + | ||
| 88 | + return !folderEmpty; | ||
| 80 | 89 | } | |
| 81 | 90 | ||
| 82 | 91 | /** | |
@@ -87,23 +96,25 @@ function processFolder(path: string) { | |||
| 87 | 96 | export function registerModulesFromFileSystem(moduleName: string) { | |
| 88 | 97 | initialize(); | |
| 89 | 98 | ||
| 90 | - let folderFound = false; | ||
| 99 | + let folderProcessed = false; | ||
| 100 | + let parentFolderProcessed = false; | ||
| 91 | 101 | // moduleName is a folder with package.json | |
| 92 | 102 | const path = fs.path.join(fs.knownFolders.currentApp().path, moduleName); | |
| 93 | 103 | if (fs.Folder.exists(path)) { | |
| 94 | - processFolder(path); | ||
| 95 | - folderFound = true; | ||
| 104 | + folderProcessed = processFolder(path); | ||
| 96 | 105 | } | |
| 97 | 106 | ||
| 98 | 107 | // moduleName is file - load all files in its parent folder | |
| 99 | 108 | const parentName = moduleName.substr(0, moduleName.lastIndexOf(fs.path.separator)); | |
| 100 | 109 | const parentFolderPath = fs.path.join(fs.knownFolders.currentApp().path, parentName); | |
| 101 | 110 | if (fs.Folder.exists(parentFolderPath)) { | |
| 102 | - processFolder(parentFolderPath); | ||
| 103 | - folderFound = true; | ||
| 111 | + parentFolderProcessed = processFolder(parentFolderPath); | ||
| 104 | 112 | } | |
| 105 | 113 | ||
| 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)) { | ||
| 107 | 118 | return; | |
| 108 | 119 | } | |
| 109 | 120 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments