1 | const Command = require('../utils/command')
|
2 | const { track } = require('../utils/telemetry')
|
3 |
|
4 | class LogoutCommand extends Command {
|
5 | async run() {
|
6 | const [accessToken, location] = this.getConfigToken()
|
7 |
|
8 | if (!accessToken) {
|
9 | this.log(`Already logged out`)
|
10 | this.log()
|
11 | this.log('To login run "netlify login"')
|
12 | this.exit()
|
13 | }
|
14 |
|
15 | await track('user_logout')
|
16 |
|
17 |
|
18 | this.netlify.globalConfig.set('userId', null)
|
19 |
|
20 | if (location === 'env') {
|
21 | this.log('The "process.env.NETLIFY_AUTH_TOKEN" is still set in your terminal session')
|
22 | this.log()
|
23 | this.log('To logout completely, unset the environment variable')
|
24 | this.log()
|
25 | this.exit()
|
26 | }
|
27 |
|
28 | this.log(`Logging you out of Netlify. Come back soon!`)
|
29 | }
|
30 | }
|
31 |
|
32 | LogoutCommand.description = `Logout of your Netlify account`
|
33 |
|
34 | LogoutCommand.hidden = true
|
35 |
|
36 | module.exports = LogoutCommand
|