const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); function findFile(dir, findStr) { if (!fs.existsSync(dir)) return false; fs.readdirSync(dir).forEach(fileName => { findStr.forEach(module => { if (fileName.indexOf(module.dir) !== -1) { module.component.forEach(compo => { execSync(`npm uninstall ${compo}`);
execSync(`npm install ${compo} --registry=https://g.civnet.cn:4873`);
}); } }); }); } findFile(path.resolve(process.cwd(), 'node_modules'), [ { dir: '@wisdom-utils', component: ['@wisdom-utils/components', '@wisdom-utils/runtime', '@wisdom-utils/utils'] }, ]);