29 lines
906 B
JavaScript
29 lines
906 B
JavaScript
import path from "node:path";
|
|
import fs from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { getLoadAnimation } from "./utils/index.mjs";
|
|
|
|
const loadAnimation = getLoadAnimation("正在扫描命令文件...");
|
|
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const scriptsDir = path.join(dirname, "../scripts");
|
|
|
|
try {
|
|
loadAnimation.start();
|
|
const commandFiles = fs
|
|
.readdirSync(scriptsDir)
|
|
.filter((file) => {
|
|
const isMjsFile = path.extname(file) === ".mjs";
|
|
const isNotIndex = file !== "index.mjs";
|
|
return isMjsFile && isNotIndex;
|
|
})
|
|
.map((file) => path.basename(file, ".mjs"));
|
|
|
|
loadAnimation.succeed("找到以下可用脚本:");
|
|
console.log("\n" + commandFiles.map((name) => ` 📦 ${name}`).join("\n"));
|
|
} catch (error) {
|
|
loadAnimation.fail("扫描脚本失败");
|
|
console.error(error);
|
|
} finally {
|
|
loadAnimation.stop();
|
|
}
|