Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Add truffle org to permission checking
Browse files Browse the repository at this point in the history
  • Loading branch information
gnidan committed Aug 22, 2019
1 parent b78a8c8 commit d327273
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions scripts/npm-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ const getPkgPermissions = userOrOrg => {
return JSON.parse(stringResponse);
};

const truffleSuiteOrgPermissionsObject = getPkgPermissions("trufflesuite");
const orgs = ["trufflesuite", "truffle"];

const getNpmUsername = () => {
const bufferResponse = execSync("npm whoami");
return bufferResponse.toString();
};
for (let org of orgs) {
const permissions = getPkgPermissions(org);

const getNpmUsername = () => {
const bufferResponse = execSync("npm whoami");
return bufferResponse.toString();
};

const username = getNpmUsername();
const username = getNpmUsername();

const userPermissionsObject = getPkgPermissions(username);
const userPermissionsObject = getPkgPermissions(username);

for (const pkg in truffleSuiteOrgPermissionsObject) {
if (!userPermissionsObject[pkg])
throw new Error(`You don't have permissions to publish ${pkg}`);
if (truffleSuiteOrgPermissionsObject[pkg] !== userPermissionsObject[pkg])
throw new Error(`Missing correct 'read-write' access to ${pkg}`);
for (const pkg in permissions) {
if (!userPermissionsObject[pkg])
throw new Error(`You don't have permissions to publish ${pkg}`);
if (permissions[pkg] !== userPermissionsObject[pkg])
throw new Error(`Missing correct 'read-write' access to ${pkg}`);
}
}

0 comments on commit d327273

Please sign in to comment.