Skip to content

Commit fe353aa

Browse files
committed
fix: fix custom tags of create post
1 parent 43ae2a0 commit fe353aa

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/commands/create/post.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)