From 23bfb7a6c48ccdb4fc6a1322e260415b7ad1a68b Mon Sep 17 00:00:00 2001 From: xuexb Date: Sun, 15 Oct 2017 14:14:12 +0800 Subject: [PATCH] fix: get tag list --- src/utils.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils.js b/src/utils.js index 62ac673..e61b010 100755 --- a/src/utils.js +++ b/src/utils.js @@ -107,12 +107,18 @@ const utils = { /** * 获取本地 git 目录的 tag 列表 * - * @param {string} options.dir git 目录 + * @param {Object} options 配置 + * @param {string} options.dir git 目录 * * @return {Array} */ - getTags({dir}) { - return execSync(`cd ${dir} && git tag -l`).toString().split(/\n+/).filter(tag => !!tag).reverse(); + getTags(options) { + const shell = [ + 'cd {dir}', + 'git describe --tags `git rev-list --tags --abbrev=0` --abbrev=0 | uniq' + ].join(' && '); + + return execSync(format(shell, options)).toString().split(/\n+/).filter(tag => !!tag); }, /**