Skip to content

Commit e6df315

Browse files
committed
refactor(migration): Make check for promise more reliable
1 parent 2553cd7 commit e6df315

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/skeleton.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ var Promise = require('bluebird');
44
var lpad = require('./util').lpad;
55
var Class = require('./class');
66

7+
function isPromise( probe ) {
8+
9+
return probe instanceof Promise || ( probe && probe.then &&
10+
probe.constructor && probe.constructor.name === 'Promise' );
11+
}
12+
713
function formatPath(dir, name) {
814
return path.join(dir, name);
915
}
@@ -75,7 +81,7 @@ var Skeleton = Class.extend({
7581
migration = require(this.path).up.apply(this, params);
7682

7783
if( migration === null ) migration = Promise.resolve();
78-
if( migration instanceof Promise ) {
84+
if( isPromise( migration ) ) {
7985

8086
migration
8187
.then(function() {
@@ -118,7 +124,7 @@ var Skeleton = Class.extend({
118124
migration = require(this.path).down.apply(this, params);
119125

120126
if( migration === null ) migration = Promise.resolve();
121-
if( migration instanceof Promise ) {
127+
if( isPromise( migration ) ) {
122128

123129
migration
124130
.then(function() {

0 commit comments

Comments
 (0)