@@ -47,6 +47,7 @@ module.exports = function(api, argv, opts, BASE_ROOT) {
4747 ...categoriesOpts . map ( item => ( { name : item , value : item } ) ) ,
4848 { name : '>>> Custom >>>' , value : CUSTOM_KEY } ,
4949 ] ,
50+ pageSize : 10 ,
5051 } ) ) ;
5152 }
5253 _chain = _chain . then ( key => {
@@ -71,23 +72,28 @@ module.exports = function(api, argv, opts, BASE_ROOT) {
7172 if ( fs . existsSync ( tagsCachePath ) ) {
7273 tagsCache = fs . readJSONSync ( tagsCachePath ) ;
7374 }
74- const tagsOpts = _ . uniq ( [ ] . concat ( createCommand . tags || [ ] ) . concat ( tagsCache || [ ] ) ) ;
75+ const tagsOpts = _ . uniq ( [ CUSTOM_KEY ] . concat ( createCommand . tags || [ ] ) . concat ( tagsCache || [ ] ) ) ;
7576 let _chain = Promise . resolve ( [ ] ) ;
76- if ( tagsOpts . length ) {
77+ if ( tagsOpts . length > 1 ) {
7778 _chain = _chain . then ( ( ) => prompt . check ( 'Select Tags:' , {
7879 choices : [
7980 ...tagsOpts . map ( item => ( { name : item , value : item } ) ) ,
8081 ] ,
82+ pageSize : 10 ,
8183 } ) ) ;
8284 }
83- _chain = _chain . then ( key => {
84- if ( key && key . length <= 0 ) {
85+ _chain = _chain . then ( keys => {
86+ if ( keys && ( keys . length <= 0 || keys . includes ( CUSTOM_KEY ) ) ) {
8587 return prompt . input ( 'Enter Tags:' ) . then ( answer => {
86- const tags = answer . trim ( ) ;
88+ let tags = answer . trim ( ) ;
89+ if ( tags ) {
90+ const _tags = tags . split ( ',' ) ;
91+ tags = _ . uniq ( keys . concat ( _tags ) . filter ( k => k !== CUSTOM_KEY ) ) . join ( ',' ) ;
92+ }
8793 info . tags = `[${ tags } ]` ;
8894 } ) ;
8995 }
90- const tags = key . join ( ',' ) ;
96+ const tags = keys . join ( ',' ) ;
9197 info . tags = `[${ tags } ]` ;
9298 } ) ;
9399 return _chain ;
0 commit comments