UNPKG

644 BJavaScriptView Raw
1const Command = require('../base')
2const renderShortDesc = require('../utils/renderShortDescription')
3const { track } = require('../utils/telemetry')
4
5class LogoutCommand extends Command {
6 async run() {
7 const accessToken = this.getAuthToken()
8
9 if (accessToken) {
10 await track('user_logout')
11
12 // unset userID without deleting key
13 this.netlify.globalConfig.set('userId', null)
14
15 this.log(`Logging you out of Netlify. Come back soon!`)
16
17 } else {
18 this.log(`Already logged out`)
19 }
20 }
21}
22
23LogoutCommand.description = `${renderShortDesc('Logout of your Netlify account')}`
24
25module.exports = LogoutCommand