1
- var optimist = require ( 'optimist ' ) ;
1
+ var yargs = require ( 'yargs ' ) ;
2
2
var log = require ( 'db-migrate-shared' ) . log ;
3
3
4
4
module . exports = function ( internals , isModule ) {
@@ -20,7 +20,7 @@ module.exports = function (internals, isModule) {
20
20
} ;
21
21
22
22
if ( ! isModule ) {
23
- internals . argv = optimist
23
+ internals . argv = yargs
24
24
. default ( defaultConfig )
25
25
. usage (
26
26
'Usage: db-migrate [up|down|check|reset|sync|create|db|transition] ' +
@@ -110,29 +110,25 @@ module.exports = function (internals, isModule) {
110
110
. describe ( 'ignore-completed-migrations' , 'Start at the first migration' )
111
111
. boolean ( 'ignore-completed-migrations' )
112
112
. describe ( 'log-level' , 'Set the log-level, for example sql|warn' )
113
- . string ( 'log-level' ) ;
113
+ . string ( 'log-level' )
114
+ . parse ( )
114
115
} else {
115
- const _internalsArgv = Object . assign ( defaultConfig , internals . cmdOptions ) ;
116
- internals . argv = {
117
- get argv ( ) {
118
- return _internalsArgv ;
119
- }
120
- } ;
116
+ internals . argv = Object . assign ( defaultConfig , internals . cmdOptions ) ;
121
117
}
122
118
123
119
var plugins = internals . plugins ;
124
120
var plugin = plugins . hook ( 'init:cli:config:hook' ) ;
125
- var _config = internals . argv . argv . config ;
121
+ var _config = internals . argv . config ;
126
122
127
123
if ( plugin ) {
128
124
plugin . forEach ( function ( plugin ) {
129
125
// var configs = plugin['init:cli:config:hook']();
130
126
// if (!configs) return;
131
- // hook not yet used, we look into migrating away from optimist first
127
+ // hook not yet used, we look into migrating away from yargs first
132
128
} ) ;
133
129
}
134
130
135
- internals . argv = deepExtend ( internals . argv . argv , rc ( 'db-migrate' , { } ) ) ;
131
+ internals . argv = deepExtend ( internals . argv , rc ( 'db-migrate' , { } ) ) ;
136
132
internals . argv . rcconfig = internals . argv . config ;
137
133
internals . argv . config = internals . argv . configFile || _config ;
138
134
@@ -142,7 +138,7 @@ module.exports = function (internals, isModule) {
142
138
}
143
139
144
140
if ( ! isModule && ( internals . argv . help || internals . argv . _ . length === 0 ) ) {
145
- optimist . showHelp ( ) ;
141
+ yargs . showHelp ( ) ;
146
142
process . exit ( 1 ) ;
147
143
}
148
144
0 commit comments