UNPKG

csdnsynchexo

Version:

支持csdn/博客园/掘金/segmentfault/腾讯云加社区等平台一键迁移hexo

24 lines (23 loc) 900 B
import { initPlatformExtension } from '../decorator/platform.js'; import { success } from '../log/index.js'; import { writeFile } from './writeFile.js'; export const run = async function (param, pure = false) { const extensions = await initPlatformExtension(); success(`加载插件完成 ${Object.keys(extensions).join(',')}`); if (extensions[param.type]) { const extension = new extensions[param.type](param); const list = await extension.run(); if (pure) { return list; } const file = writeFile(list, extension.config.output); // 生成文件后的操作 await new Promise((res) => setTimeout(() => res(), 2000)); // 同步后也不是马上? await extension.generateSuccess(file); return list; } else { throw new Error(`invalid type: ${param.type}, Please check`); } };