UNPKG

765 BJavaScriptView Raw
1const Command = require('../base')
2const renderShortDesc = require('../utils/renderShortDescription')
3const chalk = require('chalk')
4
5class LoginCommand extends Command {
6 async run() {
7 const accessToken = this.getAuthToken()
8
9 if (accessToken) {
10 this.log('Already logged in!')
11 this.log()
12 this.log(`Run ${chalk.cyanBright('netlify status')} for account details`)
13 this.log()
14 this.log(`To see all available commands run: ${chalk.cyanBright('netlify help')}`)
15 this.log()
16 return this.exit()
17 }
18
19 await this.authenticate()
20
21 return this.exit()
22 }
23}
24
25LoginCommand.description = `${renderShortDesc('Login to your Netlify account')}
26
27Opens a web browser to acquire an OAuth token.`
28
29module.exports = LoginCommand