2020-02-13 23:14:08 +08:00
|
|
|
/**
|
|
|
|
* npm run owner -- add sobear
|
|
|
|
* npm run owner -- rm sobear
|
|
|
|
* npm run owner -- ls
|
|
|
|
*/
|
2020-04-14 21:22:34 +08:00
|
|
|
import * as spawn from 'cross-spawn';
|
2020-02-13 23:14:08 +08:00
|
|
|
import getPackages from './fn/getPackages';
|
|
|
|
|
|
|
|
(async function () {
|
|
|
|
const args = process.argv;
|
|
|
|
const action = args[2];
|
|
|
|
const name = args[3];
|
2020-03-11 18:13:56 +08:00
|
|
|
const { packageNames } = await getPackages();
|
2020-02-13 23:14:08 +08:00
|
|
|
|
2020-08-22 18:59:43 +08:00
|
|
|
// eslint-disable-next-line
|
|
|
|
for(const packageName of packageNames) {
|
2020-02-13 23:14:08 +08:00
|
|
|
// https://www.npmjs.cn/cli/owner/
|
2020-08-22 18:59:43 +08:00
|
|
|
const params = action === 'ls' ? ['owner', action, packageName] : ['owner', action, name, packageName];
|
|
|
|
console.log(`\nnpm owner ${action} ${name || ''} ${packageName}`);
|
2020-04-14 21:22:34 +08:00
|
|
|
spawn.sync('npm', params, { stdio: 'inherit' });
|
2020-08-22 18:59:43 +08:00
|
|
|
console.log('added successfully...');
|
|
|
|
}
|
2020-04-14 21:22:34 +08:00
|
|
|
})();
|