Skip to content

Commit

Permalink
Allow both sails-* or * (backwards compat).
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil committed Oct 10, 2013
1 parent 73f9afa commit 0f05899
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/hooks/orm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ module.exports = function(sails) {
// sails.log.warn('Trying to load it as an adapter instead-- using module ' +
// '`sails-' + connectionName + '` with its default settings...'
// );
_ensureAdapter( connectionName );
return { adapter: 'sails-' + connectionName };
var loadedModuleName = _ensureAdapter( connectionName );
return { adapter: loadedModuleName };

// TODO: consider removing the above tolerance in 0.10.x
// return FatalError.__UnknownConnection__ (connectionName, modelID);
Expand Down Expand Up @@ -311,6 +311,8 @@ module.exports = function(sails) {
/**
* Make sure the specified adapter is loaded
* If not, try to require() it.
*
* @returns name of the module that Sails was able to load, otherwise, fatal error
*/
function _ensureAdapter ( moduleName ) {

Expand All @@ -328,7 +330,7 @@ module.exports = function(sails) {
var modulePath = sails.config.appPath + '/node_modules/' + moduleName;
if ( !fs.existsSync (modulePath) ) {
// If adapter doesn't exist, log an error and exit
return FatalError.__UnknownAdapter__ (moduleName, modelID);
return FatalError.__UnknownAdapter__ (moduleName);
}

// Since the module seems to exist, try to require it (execute the code)
Expand All @@ -339,6 +341,9 @@ module.exports = function(sails) {
return FatalError.__InvalidAdapter__ (moduleName, err);
}
}

// Return `sails-*` module name
return moduleName;
}


Expand Down

0 comments on commit 0f05899

Please sign in to comment.