1 | const Command = require('../base')
|
2 | const renderShortDesc = require('../utils/renderShortDescription')
|
3 | const chalk = require('chalk')
|
4 |
|
5 | class 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 |
|
25 | LoginCommand.description = `${renderShortDesc('Login to your Netlify account')}
|
26 |
|
27 | Opens a web browser to acquire an OAuth token.`
|
28 |
|
29 | module.exports = LoginCommand
|