Skip to content

Commit 8facc16

Browse files
committed
fix(tag): deploy flow
1 parent 2ee79cf commit 8facc16

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ const config = {
1515

1616
if (mod) {
1717
if (mod === 'triggers') {
18-
config.testRegex = `/__tests__/triggers/.*.test.js`;
18+
config.testRegex = `/__tests__/triggers/.*.test.(js|ts)`;
1919
} else {
20-
config.testRegex = `/__tests__/${process.env.MODULE}.test.js`;
20+
config.testRegex = `/__tests__/${process.env.MODULE}.test.(js|ts)`;
2121
config.testPathIgnorePatterns = ['/node_modules/'];
2222
}
2323
}

src/modules/tag/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,23 @@ export default class Tag {
7676
Offset: offset,
7777
TagKeys: tagKeys,
7878
});
79-
if (TotalCount > limit) {
79+
if (Tags.length > 0 && TotalCount > limit) {
8080
return Tags.concat(await this.getTagList(tagKeys, offset + limit, limit));
8181
}
8282

8383
return Tags;
8484
}
8585

86+
async getTag(tag: TagData) {
87+
const { Tags } = await this.request({
88+
Action: 'DescribeTags',
89+
TagKey: tag.TagKey,
90+
TagValue: tag.TagValue,
91+
});
92+
93+
return Tags[0];
94+
}
95+
8696
isTagExist(tag: TagData, tagList: TagData[] = []) {
8797
const [exist] = tagList.filter(
8898
(item) => item.TagKey === tag.TagKey && String(item.TagValue) === String(tag.TagValue),
@@ -109,12 +119,9 @@ export default class Tag {
109119
ResourcePrefix: resourcePrefix,
110120
};
111121
if (tags && tags.length > 0) {
112-
const tagKeys = tags.map((item) => item.TagKey);
113-
const tagList = await this.getTagList(tagKeys);
114-
115122
for (let i = 0; i < tags.length; i++) {
116123
const currentTag = tags[i];
117-
const tagExist = await this.isTagExist(currentTag, tagList);
124+
const tagExist = await this.getTag(currentTag);
118125

119126
// if tag not exsit, create it
120127
if (!tagExist) {

0 commit comments

Comments
 (0)