UNPKG

732 BJavaScriptView Raw
1'use strict'
2
3let cli = require('heroku-cli-util')
4let co = require('co')
5
6function * run (context, heroku) {
7 let request = heroku.get('/account')
8 .then(function (user) {
9 return heroku.delete(`/apps/${context.app}/collaborators/${encodeURIComponent(user.email)}`).catch(function (err) {
10 console.log(err)
11 throw new Error(err.body)
12 })
13 })
14 yield cli.action(`Leaving ${cli.color.cyan(context.app)}`, request)
15}
16
17let cmd = {
18 topic: 'apps',
19 command: 'leave',
20 description: 'remove yourself from an organization app',
21 needsAuth: true,
22 needsApp: true,
23 run: cli.command(co.wrap(run))
24}
25
26module.exports.apps = cmd
27module.exports.root = Object.assign({}, cmd, {topic: 'leave', command: null})