Skip to content

Commit

Permalink
Merge branch 'main' into fix/issue-126
Browse files Browse the repository at this point in the history
  • Loading branch information
A-kirami authored Mar 1, 2024
2 parents abf2394 + 5e3d775 commit 85e475b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/formatArtifactComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@
*/
function createMarkdownTableRow({ name, size_in_bytes, url }) {
const platform = name.split('_')[2]
return `| ${platform} | [${name}](${url}) | ${size_in_bytes / 1024 ** 2} MB |`
const fileSize = (size_in_bytes / 1024 ** 2).toFixed(2)
return `| ${platform} | [${name}](${url}) | ${fileSize} MB |`
}

function createMarkdownTableHeader() {
return ['| 平台 | 文件名 | 大小 |', '| --- | --- | --- |']
return ['| 平台 | 文件 | 大小 |', '| --- | --- | --- |']
}

/**
* @param {{name: string, size_in_bytes: number, url: string}[]} artifacts
*/
function createArtifactComment(artifacts) {
const tableHeader = createMarkdownTableHeader()
const tableBody = artifacts.map((artifact) => createMarkdownTableRow(artifact))
const tableBody = artifacts
.sort((a, b) => a.name.localeCompare(b.name))
.map((artifact) => createMarkdownTableRow(artifact))
const comment = ['### 📦️ 此 PR 构建的应用已经准备就绪', '', ...tableHeader, ...tableBody, '']
return comment.join('\n')
}
Expand Down

0 comments on commit 85e475b

Please sign in to comment.