-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(git): 從 git 的 tag 列表中取得已經推送過的版本列表
- Loading branch information
1 parent
f1f1a88
commit dcada6b
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}) | ||
}) | ||
; | ||
} |