Created
August 22, 2018 16:29
-
-
Save jdx/80cc59ca42708d5ba98920d0c6fa5bcf to your computer and use it in GitHub Desktop.
add npm users to org members
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const Client = require('npm-registry-client') | |
const reg = new Client() | |
const uri = 'https://registry.npmjs.org/npm' | |
const csv = require('csv') | |
const fs = require('fs') | |
const PARAMS = {auth: {token: process.env.NPM_PASS}, org: 'heroku'} | |
csv.parse(fs.readFileSync('users.csv'), (err, csv) => { | |
if (err) throw err | |
reg.org('ls', uri, {...PARAMS}, (err, roster) => { | |
if (err) throw err | |
let firstline = true | |
for (let line of csv) { | |
if (firstline) { | |
firstline = false | |
continue | |
} | |
const user = line[2] | |
if (roster[user]) continue | |
console.log(`adding ${user}`) | |
reg.org('add', uri, {...PARAMS, user}, (err, roster) => { | |
}) | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment