31 lines
666 B
JavaScript
31 lines
666 B
JavaScript
|
const fs = require('fs')
|
||
|
const path = require('path')
|
||
|
|
||
|
const cmds = {}
|
||
|
|
||
|
let list = fs.readdirSync(path.resolve(__dirname))
|
||
|
let actGrpFile = list.filter(t => {
|
||
|
if (t.startsWith('index')) return false
|
||
|
let stat = fs.statSync(path.resolve(__dirname, t))
|
||
|
return stat.isFile
|
||
|
})
|
||
|
|
||
|
let allowExt = /^\.(js)$/i
|
||
|
for (let i of actGrpFile) {
|
||
|
let ext = path.extname(i)
|
||
|
let fp = path.resolve(__dirname, i)
|
||
|
|
||
|
if (!allowExt.test(ext)) continue
|
||
|
|
||
|
let tmp = require(fp)
|
||
|
for (let j in tmp) {
|
||
|
cmds[j] = tmp[j]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const runAct = async (cmd, txt = '', source = {}) => {
|
||
|
if (!cmd || typeof cmd !== 'string' || cmd.length === 0) return null
|
||
|
}
|
||
|
|
||
|
module.exports = runAct
|