install.js 688 Bytes
Newer Older
杨思琦's avatar
杨思琦 committed
1 2 3 4 5 6 7 8 9 10 11
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}`);
杨思琦's avatar
杨思琦 committed
12
          execSync(`npm install ${compo} --registry=https://g.civnet.cn:4873`);
杨思琦's avatar
杨思琦 committed
13 14 15 16 17 18 19 20 21
        });
      }
    });
  });
}

findFile(path.resolve(process.cwd(), 'node_modules'), [
  { dir: '@wisdom-utils', component: ['@wisdom-utils/components', '@wisdom-utils/runtime', '@wisdom-utils/utils'] },
]);