syncTNPM.js 746 Bytes
Newer Older
dengxiaofeng's avatar
dengxiaofeng committed
1 2 3 4 5 6 7
const { execa } = require('@umijs/utils');
const { join } = require('path');
const getPackages = require('./utils/getPackages');

process.setMaxListeners(Infinity);

module.exports = (publishPkgList) => {
8
  const pkgList = (publishPkgList || getPackages()).map((pkg) => {
邓晓峰's avatar
邓晓峰 committed
9
    // eslint-disable-next-line global-require,import/no-dynamic-require
10 11 12
    const [name, path] = pkg.split('!');
    // eslint-disable-next-line global-require,import/no-dynamic-require
    return require(join(__dirname, '../packages', path, name, 'package.json')).name;
dengxiaofeng's avatar
dengxiaofeng committed
13 14 15 16 17 18 19
  });
  const commands = pkgList.map((pkg) => {
    const subprocess = execa('tnpm', ['sync', pkg]);
    subprocess.stdout.pipe(process.stdout);
    return subprocess;
  });
  Promise.all(commands);
邓晓峰's avatar
邓晓峰 committed
20
};