Skip to content

Commit ad4d8f6

Browse files
committed
detect real callback for several api functions
1 parent 1bae0b5 commit ad4d8f6

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

api.js

+29-9
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function registerEvents() {
8787
process.exit(1);
8888
});
8989

90-
process.on('unhandledRejection', function(reason, promise) {
90+
process.on('unhandledRejection', function(reason) {
9191
log.error(reason.stack);
9292
process.exit(1);
9393
});
@@ -159,7 +159,7 @@ dbmigrate.prototype = {
159159
*
160160
* Defaults to up all migrations if no count is given.
161161
*/
162-
up: function(specification, scope, callback) {
162+
up: function(specification, opts, callback) {
163163

164164
if (arguments.length > 0) {
165165
if (typeof(specification) === 'string') {
@@ -169,10 +169,18 @@ dbmigrate.prototype = {
169169

170170
this.internals.argv.count = specification;
171171
}
172+
else if (typeof(specification) === 'function') {
172173

173-
if (scope) {
174+
callback = specification;
175+
}
174176

175-
this.internals.migrationMode = scope;
177+
if (typeof(opts) === 'string') {
178+
179+
this.internals.migrationMode = opts;
180+
}
181+
else if (typeof(opts) === 'function') {
182+
183+
callback = opts;
176184
}
177185
}
178186

@@ -184,17 +192,25 @@ dbmigrate.prototype = {
184192
*
185193
* Defaults to up all migrations if no count is given.
186194
*/
187-
down: function(specification, scope, callback) {
195+
down: function(specification, opts, callback) {
188196

189197
if (arguments.length > 0) {
190-
if (typeof(arguments[0]) === 'number') {
198+
if (typeof(specification) === 'number') {
191199

192200
this.internals.argv.count = arguments[0];
193201
}
202+
else if (typeof(specification) === 'function') {
194203

195-
if (scope) {
204+
callback = specification;
205+
}
196206

197-
this.internals.migrationMode = scope;
207+
if (typeof(opts) === 'string') {
208+
209+
this.internals.migrationMode = opts;
210+
}
211+
else if (typeof(opts) === 'function') {
212+
213+
callback = opts;
198214
}
199215
}
200216

@@ -206,10 +222,14 @@ dbmigrate.prototype = {
206222
*/
207223
reset: function(scope, callback) {
208224

209-
if (scope) {
225+
if (typeof(scope) === 'string') {
210226

211227
this.internals.migrationMode = scope;
212228
}
229+
else if(typeof(scope) === 'function') {
230+
231+
callback = scope;
232+
}
213233

214234
this.internals.argv.count = Number.MAX_VALUE;
215235
executeDown(this.internals, this.config, callback);

lib/driver/shadow.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ exports.infect = function(db, intern, ShadowProto) {
3939

4040
db[property] = function() {
4141
var params = arguments,
42-
self = this,
43-
callback;
42+
self = this;
4443

4544
return self._shadowProto[property].apply(self, params)
4645
.then( function() {

0 commit comments

Comments
 (0)