mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-03 11:47:48 +08:00
9172120d52
* test(ci): add build product checking for prs - Add build product testing to the CI * Fix error syntax * Tweak with output table
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import fs from 'fs/promises'
|
|
import path from 'path'
|
|
|
|
main()
|
|
|
|
async function main() {
|
|
let output: string
|
|
const diffOutput = await fs.readFile(
|
|
path.resolve(__dirname, '..', 'tmp/diff.txt'),
|
|
'utf-8'
|
|
)
|
|
const fileDiffs = diffOutput
|
|
.split('\n')
|
|
.map((s) => s.trim())
|
|
.filter((s) => s)
|
|
.map((s) => s.split(':'))
|
|
|
|
if (fileDiffs.length === 0) {
|
|
output = ''
|
|
} else {
|
|
const table = fileDiffs.reduce(
|
|
(prev, [source, filename]) => {
|
|
const row = `|${filename}`
|
|
let status: 'Added 🟢' | 'Removed ⛔️'
|
|
if (!source.startsWith('./dist')) {
|
|
status = 'Removed ⛔️'
|
|
} else {
|
|
status = 'Added 🟢'
|
|
}
|
|
return `${prev}
|
|
${row}|${status}|`
|
|
},
|
|
`| Filename | Status |
|
|
|:---|:---:|`
|
|
)
|
|
|
|
output = `**Total changed files:** ${fileDiffs.length}
|
|
|
|
<details><summary>:information_source: Files have been changed</summary>
|
|
|
|
${table}
|
|
|
|
</details>
|
|
|
|
<sub>Generated with :heart: by Element Plus bot</sub>`
|
|
}
|
|
|
|
await fs.writeFile(path.resolve(__dirname, '..', 'tmp/diff.md'), output)
|
|
}
|