mastercontroller 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/MasterControl.js +21 -12
  2. package/package.json +1 -1
package/MasterControl.js CHANGED
@@ -151,19 +151,25 @@ class MasterControl {
151
151
 
152
152
  component(folderLocation, innerFolder){
153
153
 
154
- var rootFolderLocation = `${this.root}/${folderLocation}/${innerFolder}`;
155
- var search = `${rootFolderLocation}/**/*config.js`;
156
- var files = globSearch.sync(search, rootFolderLocation);
157
- require(files[0]);
158
- var searchRoutes = `${rootFolderLocation}/**/*routes.js`;
159
- var routeFiles = globSearch.sync(searchRoutes, rootFolderLocation);
160
- var route = routeFiles[0];
154
+ var rootFolderLocation = path.join(this.root, folderLocation, innerFolder);
155
+ var files = globSearch.sync("**/*config.js", { cwd: rootFolderLocation, absolute: true });
156
+ if(files && files.length > 0){
157
+ require(files[0]);
158
+ }else{
159
+ master.error.log(`Cannot find config file under ${rootFolderLocation}`, "error");
160
+ }
161
+ var routeFiles = globSearch.sync("**/*routes.js", { cwd: rootFolderLocation, absolute: true });
162
+ var route = routeFiles && routeFiles.length > 0 ? routeFiles[0] : null;
161
163
  var routeObject = {
162
164
  isComponent : true,
163
165
  root : rootFolderLocation
164
166
  }
165
167
  this.router.setup(routeObject);
166
- require(route);
168
+ if(route){
169
+ require(route);
170
+ }else{
171
+ master.error.log(`Cannot find routes file under ${rootFolderLocation}`, "error");
172
+ }
167
173
  }
168
174
 
169
175
 
@@ -464,15 +470,18 @@ class MasterControl {
464
470
  }
465
471
 
466
472
  startMVC(foldername){
467
- var rootFolderLocation = `${this.root}/${foldername}`;
468
- var search = `${rootFolderLocation}/**/*routes.js`;
469
- var files = globSearch.sync(search, rootFolderLocation);
473
+ var rootFolderLocation = path.join(this.root, foldername);
474
+ var files = globSearch.sync("**/*routes.js", { cwd: rootFolderLocation, absolute: true });
470
475
  var route = {
471
476
  isComponent : false,
472
477
  root : `${this.root}`
473
478
  }
474
479
  this.router.setup(route);
475
- require(files[0]);
480
+ if(files && files.length > 0){
481
+ require(files[0]);
482
+ }else{
483
+ master.error.log(`Cannot find routes file under ${rootFolderLocation}`, "error");
484
+ }
476
485
  }
477
486
 
478
487
 
package/package.json CHANGED
@@ -18,5 +18,5 @@
18
18
  "scripts": {
19
19
  "test": "echo \"Error: no test specified\" && exit 1"
20
20
  },
21
- "version": "1.2.5"
21
+ "version": "1.2.6"
22
22
  }