Skip to content

Commit

Permalink
fix(git): 從 git 的 tag 列表中取得已經推送過的版本列表
Browse files Browse the repository at this point in the history
  • Loading branch information
bluelovers committed Jul 27, 2022
1 parent f1f1a88 commit dcada6b
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions lib/git/update-publish-tags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { getSourceInfoSync } from '../build/get-source-info';
import { outputJSON, readJSON } from 'fs-extra';
import { __file_publish_tags_json } from '../const';
import { array_unique_overwrite } from 'array-hyper-unique';
import { LF } from 'crlf-normalize';
import { buildCmd, gitTagList } from '@git-lazy/tag-list';
import { console } from 'debug-color2';
import { __root } from '../../test/__root';

export function updatePublishTags()
{
return readJSON(__file_publish_tags_json)
.catch(e => [])
.then(async (tags: string[]) =>
{
const __pluginVersion = getSourceInfoSync().pluginMeta.version;

if (!tags.includes(__pluginVersion))
{
tags.push(__pluginVersion);
}

await gitTagList({
cwd: __root,
target: null,
})
.each(row => {

const m = /^v(\d+\.\d+)$/.exec(row[0]);

if (m?.[1])
{
tags.push(m[1]);
}

})
;

return array_unique_overwrite(tags.filter(v => v))
})
.then(tags =>
{
return outputJSON(__file_publish_tags_json, tags, {
spaces: 2,
EOL: LF,
})
})
;
}

0 comments on commit dcada6b

Please sign in to comment.