Add support for bot token
This commit is contained in:
25
utils/build.mjs
Normal file
25
utils/build.mjs
Normal file
@@ -0,0 +1,25 @@
|
||||
//Imports
|
||||
import fs from "fs"
|
||||
import path from "path"
|
||||
import url from "url"
|
||||
import ncc from "@vercel/ncc"
|
||||
|
||||
//Dirname
|
||||
const __dirname = path.join(path.dirname(url.fileURLToPath(import.meta.url)), "..", "action")
|
||||
|
||||
//Build code
|
||||
let {code} = await ncc(`${__dirname}/index.mjs`, {
|
||||
minify:true,
|
||||
sourceMap:false,
|
||||
sourceMapRegister:false,
|
||||
})
|
||||
|
||||
//Perform static includes
|
||||
for (const match of [...code.match(/(?<=`)<#include (.+?)>(?=`)/g)]) {
|
||||
const file = match.match(/<#include (.+?)>/)[1]
|
||||
code = code.replace(`<#include ${file}>`, `${await fs.promises.readFile(path.join("src", file))}`.replace(/([$`])/g, "\\$1"))
|
||||
console.log(`Included ${file}`)
|
||||
}
|
||||
|
||||
//Save build
|
||||
await fs.promises.writeFile(`${__dirname}/dist/index.js`, code)
|
||||
@@ -1,12 +0,0 @@
|
||||
//Imports
|
||||
import fs from "fs"
|
||||
import path from "path"
|
||||
|
||||
//Perform static includes
|
||||
let generated = `${await fs.promises.readFile(path.join("action/dist", "index.js"))}`
|
||||
for (const match of [...generated.match(/(?<=`)<#include (.+?)>(?=`)/g)]) {
|
||||
const file = match.match(/<#include (.+?)>/)[1]
|
||||
generated = generated.replace(`<#include ${file}>`, `${await fs.promises.readFile(path.join("src", file))}`.replace(/([$`])/g, "\\$1"))
|
||||
console.log(`Included ${file}`)
|
||||
}
|
||||
await fs.promises.writeFile(path.join("action/dist", "index.js"), generated)
|
||||
Reference in New Issue
Block a user