error file output

This commit is contained in:
2022-06-08 11:56:01 -05:00
parent 6b0b604008
commit 3fdb3ad110
6 changed files with 25 additions and 8 deletions

View File

@@ -72,15 +72,17 @@ readdirSync(DistBase).forEach(file => unlinkSync(`${DistBase}/${file}`))
//compile scripts
;(async () => {
let scripts = readdirSync(ScriptBase)
// let scriptMeta: {
// [name: string]: [UserScriptMetaFull, string | null]
// } = {}
let scriptMeta: readmeData[] = []
for (let name of scripts) {
let path = ScriptPath(name)
//delete error file if it exists
if (existsSync(path.error)) {
unlinkSync(path.error)
}
if (
!name.endsWith('_') &&
existsSync(path.dir) &&
@@ -93,6 +95,14 @@ readdirSync(DistBase).forEach(file => unlinkSync(`${DistBase}/${file}`))
meta,
error,
})
//write error file
if (error !== null) {
writeFileSync(
path.error,
`${new Date().toISOString()}\n\n${error}`
)
}
}
}

View File

@@ -11,6 +11,7 @@ export const ScriptPath = (name: string) => ({
dir: `${ScriptBase}/${name}`,
main: `${ScriptBase}/${name}/main.ts`,
meta: `${ScriptBase}/${name}/meta.json`,
error: `${ScriptBase}/${name}/error.log`,
})
export const DistPath = (name: string) => `${DistBase}/${name}.user.js`