-
Notifications
You must be signed in to change notification settings - Fork 4
/
ora.js
51 lines (40 loc) · 1.25 KB
/
ora.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict'
const { Command } = require('@adonisjs/ace')
const Ora = require('ora')
class Load extends Command {
static get signature() {
return `ora`
}
static get description() {
return 'Ora spinners for long running tasks'
}
/**
* Handle the command
*
* @param {*} args arguments object, contains only data if you’ve added arguments in the signature
* @param {*} flags an object of flags where each value is either "null" or "true".
* Check the signature for available flags
*/
async handle(args, flags) {
const spinner = Ora('Fueling the rocket')
spinner.start()
await this.waitASecond()
spinner.color = 'magenta'
spinner.text = 'Boarding passengers'
await this.waitASecond()
spinner.color = 'yellow'
spinner.text = 'Starting the engines'
await this.waitASecond()
spinner.color = 'green'
spinner.text = 'Launching the rocket!!!!'
await this.waitASecond()
spinner.color = 'cyan'
spinner.text = 'Shooting for the stars'
await this.waitASecond()
spinner.succeed('Houston? We landed!')
}
waitASecond() {
return new Promise(resolve => setTimeout(resolve, 1000))
}
}
module.exports = Load