Update build and tests

This commit is contained in:
lowlighter
2020-11-06 19:59:44 +01:00
parent 21f2fa7bec
commit 8d1b29b711
6 changed files with 114 additions and 43 deletions

View File

@@ -1,11 +1,8 @@
//Imports
import path from "path"
import fs from "fs"
import build from "../utils/build.mjs"
import url from "url"
import colors from "colors"
//Initialization
const __dirname = path.join(path.dirname(url.fileURLToPath(import.meta.url)), "..", "action")
process.on("unhandledRejection", error => { throw error })
/** Test function */
@@ -16,17 +13,14 @@
/** Build test */
test.build = async function () {
//Ensure that action has been rebuild
console.log("### Checking that code has been rebuild")
const action = `${await fs.promises.readFile(`${__dirname}/dist/index.js`)}`
const code = await build()
if (action !== code)
throw new Error(`GitHub Action has not been rebuild. Run "npm run build" to solve this issue`)
//Ensure that code has been rebuild
console.log("TEST : build".cyan)
await build({actions:["check"]})
}
//Main
if (/metrics.mjs/.test(process.argv[1])) {
//Test
await test()
console.log("Test success !")
console.log("Test success !".green)
}