main: set filename of attachments

This commit is contained in:
Dawid Dziurla 2022-03-24 19:30:26 +01:00 committed by GitHub
parent f5b1987fb0
commit 6d23605227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ const core = require("@actions/core")
const glob = require("@actions/glob")
const fs = require("fs")
const showdown = require("showdown")
const path = require("path")
function getBody(bodyOrFile, convertMarkdown) {
let body = bodyOrFile
@ -33,7 +34,7 @@ function getFrom(from, username) {
async function getAttachments(attachments) {
const globber = await glob.create(attachments.split(',').join('\n'))
const files = await globber.glob()
return files.map(f => ({ path: f, cid: f.replace(/^.*[\\\/]/, '')}))
return files.map(f => ({ filename: path.basename(f), path: f, cid: f.replace(/^.*[\\\/]/, '')}))
}
async function main() {