mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-16 12:51:39 +00:00
feat(shell): filter out invalid engine
This commit is contained in:
parent
0277077fbf
commit
1ec90d1dfd
@ -24,6 +24,13 @@ export * from './types'
|
||||
|
||||
declare const __DEFINE_CHRONO_VERSION__: string
|
||||
|
||||
interface EngineInfo {
|
||||
name: string
|
||||
filename: string
|
||||
type: string
|
||||
path: string
|
||||
}
|
||||
|
||||
export const chronocat = async () => {
|
||||
l.info(`Chronocat v${__DEFINE_CHRONO_VERSION__}`)
|
||||
|
||||
@ -59,14 +66,24 @@ export const chronocat = async () => {
|
||||
recursive: true,
|
||||
})
|
||||
|
||||
const engines = readdirSync(enginesPath).map((filename) => {
|
||||
const engines = readdirSync(enginesPath)
|
||||
.map((filename) => {
|
||||
let valid = false
|
||||
let name = filename
|
||||
let type = 'js'
|
||||
|
||||
if (name.endsWith('.jsc')) {
|
||||
valid = true
|
||||
name = name.slice(0, name.length - 4)
|
||||
type = 'jsc'
|
||||
}
|
||||
if (name.endsWith('.js')) name = name.slice(0, name.length - 3)
|
||||
|
||||
if (name.endsWith('.js')) {
|
||||
valid = true
|
||||
name = name.slice(0, name.length - 3)
|
||||
}
|
||||
|
||||
if (!valid) return undefined
|
||||
|
||||
return {
|
||||
name,
|
||||
@ -75,6 +92,9 @@ export const chronocat = async () => {
|
||||
path: join(enginesPath, filename),
|
||||
}
|
||||
})
|
||||
.filter(
|
||||
Boolean as unknown as (x: EngineInfo | undefined) => x is EngineInfo,
|
||||
)
|
||||
|
||||
if (!engines.length)
|
||||
l.warn('没有找到任何引擎。Chronocat 服务仍将启动。', { code: 2156 })
|
||||
|
Loading…
Reference in New Issue
Block a user