1 | 'use strict'
|
2 |
|
3 | let cli = require('heroku-cli-util')
|
4 | let co = require('co')
|
5 |
|
6 | function * 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 |
|
17 | let 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 |
|
26 | module.exports.apps = cmd
|
27 | module.exports.root = Object.assign({}, cmd, {topic: 'leave', command: null})
|