generated from kgod/ai-review-template
feat: initialize resume agent with OfferPai sync
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const ts = require('typescript')
|
||||
|
||||
const sourceRoot = path.resolve(__dirname, '..', 'src')
|
||||
let checked = 0
|
||||
let errors = 0
|
||||
|
||||
function visit(directory) {
|
||||
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
||||
const filename = path.join(directory, entry.name)
|
||||
if (entry.isDirectory()) {
|
||||
visit(filename)
|
||||
continue
|
||||
}
|
||||
if ((!filename.endsWith('.ts') && !filename.endsWith('.vue')) || filename.endsWith('.d.ts')) {
|
||||
continue
|
||||
}
|
||||
|
||||
let source = fs.readFileSync(filename, 'utf8')
|
||||
if (filename.endsWith('.vue')) {
|
||||
const match = source.match(/<script setup lang="ts">([\s\S]*?)<\/script>/)
|
||||
if (!match) continue
|
||||
source = match[1]
|
||||
}
|
||||
const result = ts.transpileModule(source, {
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.ESNext,
|
||||
target: ts.ScriptTarget.ES2022,
|
||||
},
|
||||
fileName: filename,
|
||||
reportDiagnostics: true,
|
||||
})
|
||||
const diagnostics = (result.diagnostics || []).filter(
|
||||
(item) => item.category === ts.DiagnosticCategory.Error,
|
||||
)
|
||||
checked += 1
|
||||
if (!diagnostics.length) continue
|
||||
errors += diagnostics.length
|
||||
process.stderr.write(`${filename}\n`)
|
||||
for (const diagnostic of diagnostics) {
|
||||
process.stderr.write(` ${ts.flattenDiagnosticMessageText(diagnostic.messageText, ' ')}\n`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visit(sourceRoot)
|
||||
process.stdout.write(`checked=${checked} syntax_errors=${errors}\n`)
|
||||
process.exitCode = errors ? 1 : 0
|
||||
Reference in New Issue
Block a user