Skip to content

Commit

Permalink
Automatically merged boilerplate update from #29
Browse files Browse the repository at this point in the history
Applied 2 fixes from jaid/action-uptodater
  • Loading branch information
github-actions[bot] committed Apr 30, 2020
2 parents 5e3b8b1 + 067bacb commit 513498a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import readableMs from "readable-ms"
import yargs from "yargs"

import core from "./core"

function logError(message) {
if (core?.logger?.error) {
core.logger.error(message)
/**
* @param {*} message
* @param {string} [level="info"]
*/
function log(message, level = "info") {
if (core?.logger?.[level]) {
core.logger[level](message)
} else {
console.error(message)
console[level](message)
}
}

process.on("unhandledRejection", error => {
if (error) {
logError(`Unhandled promise rejection: ${error?.message || error}`)
} else {
logError("Unhandled promise rejection")
}
if (error?.stack) {
logError(error.stack)
}
log("Unhandled promise rejection", "error")
log(error, "error")
})

process.on("exit", code => {
log(`Exiting with code ${code} after ${readableMs(Date.now() - core.startTime)}`)
})

/**
* @return {Promise<void>}
*/
async function job() {
const plugins = {}
const pluginsRequire = require.context("./plugins/", true, /^\.\/\w+\/index.js$/)
Expand All @@ -33,7 +39,8 @@ async function job() {

function main() {
job().catch(error => {
logError("Core process crashed: %s", error)
log("Core process crashed", "error")
log(error, "error")
process.exit(1)
})
}
Expand Down
27 changes: 27 additions & 0 deletions tsconfigBase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"baseUrl": ".",
"outDir": "dist/typescript",
"newLine": "lf",
"declaration": true,
"emitDeclarationOnly": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"paths": {
"lib/*": [
"src/lib/*"
],
"src/*": [
"src/*"
],
"root/*": [
"./*"
]
}
},
"typeAcquisition": {
"enable": true
}
}

0 comments on commit 513498a

Please sign in to comment.