@@ -57,35 +57,41 @@ var Skeleton = Class.extend({
57
57
var cb_executed = false ;
58
58
59
59
return new Promise ( function ( resolve , reject ) {
60
- var r = function ( err ) {
61
- if ( cb_executed === false ) {
60
+ var migration ,
61
+ r = function ( err ) {
62
+ if ( cb_executed === false ) {
62
63
63
- cb_executed = true ;
64
+ cb_executed = true ;
64
65
65
- if ( err )
66
- reject ( err ) ;
67
- else
68
- resolve ( ) ;
69
- }
70
- } ;
66
+ if ( err )
67
+ reject ( err ) ;
68
+ else
69
+ resolve ( ) ;
70
+ }
71
+ } ;
71
72
72
73
params [ params . length ++ ] = r ;
73
74
74
- Promise . resolve ( require ( this . path ) . up . apply ( this , params ) )
75
- . then ( function ( Promise ) {
76
- if ( Promise !== undefined && cb_executed === false ) {
75
+ migration = require ( this . path ) . up . apply ( this , params ) ;
76
+
77
+ if ( migration instanceof Promise ) {
77
78
78
- cb_executed = true ;
79
- resolve ( ) ;
80
- }
81
- } ) . catch ( function ( err ) {
79
+ migration
80
+ . then ( function ( ) {
81
+ if ( cb_executed === false ) {
82
82
83
- if ( cb_executed === false ) {
83
+ cb_executed = true ;
84
+ resolve ( ) ;
85
+ }
86
+ } ) . catch ( function ( err ) {
87
+
88
+ if ( cb_executed === false ) {
84
89
85
- cb_executed = true ;
86
- reject ( err ) ;
87
- }
88
- } ) ;
90
+ cb_executed = true ;
91
+ reject ( err ) ;
92
+ }
93
+ } ) ;
94
+ }
89
95
} . bind ( this ) ) ;
90
96
} ,
91
97
@@ -94,34 +100,40 @@ var Skeleton = Class.extend({
94
100
var cb_executed = false ;
95
101
96
102
return new Promise ( function ( resolve , reject ) {
97
- var r = function ( err ) {
98
- if ( cb_executed === false ) {
103
+ var migration ,
104
+ r = function ( err ) {
105
+ if ( cb_executed === false ) {
99
106
100
- cb_executed = true ;
107
+ cb_executed = true ;
108
+
109
+ if ( err )
110
+ reject ( err ) ;
111
+ else
112
+ resolve ( ) ;
113
+ }
114
+ } ;
101
115
102
- if ( err )
103
- reject ( err ) ;
104
- else
105
- resolve ( ) ;
106
- }
107
- } ;
108
116
params [ params . length ++ ] = r ;
117
+ migration = require ( this . path ) . down . apply ( this , params ) ;
109
118
110
- Promise . resolve ( require ( this . path ) . down . apply ( this , params ) )
111
- . then ( function ( Promise ) {
112
- if ( Promise !== undefined && cb_executed === false ) {
119
+ if ( migration instanceof Promise ) {
113
120
114
- cb_executed = true ;
115
- resolve ( ) ;
116
- }
117
- } ) . catch ( function ( err ) {
121
+ migration
122
+ . then ( function ( Promise ) {
123
+ if ( Promise !== undefined && cb_executed === false ) {
118
124
119
- if ( cb_executed === false ) {
125
+ cb_executed = true ;
126
+ resolve ( ) ;
127
+ }
128
+ } ) . catch ( function ( err ) {
129
+
130
+ if ( cb_executed === false ) {
120
131
121
- cb_executed = true ;
122
- reject ( err ) ;
123
- }
124
- } ) ;
132
+ cb_executed = true ;
133
+ reject ( err ) ;
134
+ }
135
+ } ) ;
136
+ }
125
137
} . bind ( this ) ) ;
126
138
} ,
127
139
0 commit comments