MCPcopy Index your code
hub / github.com/react/react / checkNPMPermissions

Function checkNPMPermissions

scripts/devtools/utils.js:19–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17});
18
19async function checkNPMPermissions() {
20 const currentUser = await execRead('npm whoami');
21 const failedProjects = [];
22
23 const checkProject = async project => {
24 const owners = (await execRead(`npm owner ls ${project}`))
25 .split('\n')
26 .filter(owner => owner)
27 .map(owner => owner.split(' ')[0]);
28
29 if (!owners.includes(currentUser)) {
30 failedProjects.push(project);
31 }
32 };
33
34 await logger(
35 Promise.all(NPM_PACKAGES.map(checkProject)),
36 `Checking NPM permissions for ${chalk.bold(currentUser)}.`,
37 {estimate: 2500}
38 );
39
40 console.log('');
41
42 if (failedProjects.length) {
43 console.error(chalk.red.bold('Insufficient NPM permissions'));
44 console.error('');
45 console.error(
46 chalk.red(
47 `NPM user {underline ${currentUser}} is not an owner for: ${chalk.bold(
48 failedProjects.join(', ')
49 )}`
50 )
51 );
52 console.error(
53 chalk.red(
54 'Please contact a React team member to be added to the above project(s).'
55 )
56 );
57 process.exit(1);
58 }
59}
60
61function clear() {
62 console.clear();

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 6

loggerFunction · 0.85
joinMethod · 0.80
exitMethod · 0.80
execReadFunction · 0.70
mapMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected