error file output
This commit is contained in:
16
src/main.ts
16
src/main.ts
@@ -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}`
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user