lib/factories/service.factory.js
function loadIfExists(path, moduleStack, errMsg) {
        var servicesDir = this.injector.servicesDir;
        var servicesFullPath = this.injector.rootDir + '/' + servicesDir;

        // if the file doesn't exist, either throw an error (if msg passed in), else just return null
        if (!fs.existsSync(p.join(servicesFullPath, path + '.js'))) {
            if (errMsg) {
                throw new Error(errMsg + ' ' + servicesFullPath + path + '.js');
            }
            else {
                return null;
            }
        }

        // else load the module
        return this.injector.loadModule(servicesDir + path, moduleStack);
    }
function loadIfExists(path, moduleStack, errMsg) {
        var servicesDir = this.injector.servicesDir;
        var servicesFullPath = this.injector.rootDir + '/' + servicesDir;

        // if the file doesn't exist, either throw an error (if msg passed in), else just return null
        if (!fs.existsSync(p.join(servicesFullPath, path + '.js'))) {
            if (errMsg) {
                throw new Error(errMsg + ' ' + servicesFullPath + path + '.js');
            }
            else {
                return null;
            }
        }

        // else load the module
        return this.injector.loadModule(servicesDir + path, moduleStack);
    }
function loadIfExists ( path , moduleStack , errMsg ) { var servicesDir = this . injector . servicesDir ; var servicesFullPath = this . injector . rootDir + '/' + servicesDir ; // if the file doesn't exist, either throw an error (if msg passed in), else just return null if ( ! fs . existsSync ( p . join ( servicesFullPath , path + '.js' ) ) ) { if ( errMsg ) { throw new Error ( errMsg + ' ' + servicesFullPath + path + '.js' ) ; } else { return null ; } } // else load the module return this . injector . loadModule ( servicesDir + path , moduleStack ) ; }
Load a module if it exists
@param path
@param moduleStack
@param errMsg
@returns {*}
Load a module if it exists