Add support for bot token

This commit is contained in:
lowlighter
2020-10-09 13:53:03 +02:00
parent 3c6704f2c6
commit 12f6c1abf3
8 changed files with 89 additions and 10189 deletions

25
utils/build.mjs Normal file
View 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)

View File

@@ -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)