import { OptionsJSON, RegistryJSON } from '../utils/common'; import { isFileExist, selectRegistry, changeRegistryInfo, } from '../utils/publish'; const publish = async (options: OptionsJSON) => { // 判断文件是否存在 isFileExist(); const { auto } = options || {}; // 选择 npm 源 const data = await selectRegistry(auto); if (auto) { // auto: true 遍历发布到所有源 Object.keys(data).forEach((key) => { changeRegistryInfo(data[key]); }); } else { changeRegistryInfo(data as RegistryJSON); } }; export default publish;