-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
55 lines (51 loc) · 1.34 KB
/
app.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
52
53
54
55
var inquirer = require('inquirer')
var eventEmitter = require('events')
var dotenv = require('dotenv').config()
var common = require('./components/common')
var constants = require('./components/constants')
var initialize = require('./components/initialize')
var authenticate = require('./components/authenticate')
var photo = require('./components/photo')
var video = require('./components/video')
function createQuestions () {
var questions = []
questions.push({
type: 'list',
name: 'cmd',
message: 'What do you want ?',
choices: [
constants.CMD_INITIALIZE,
constants.CMD_AUTHENTICATE,
constants.CMD_POST,
constants.CMD_PHOTO,
constants.CMD_VIDEO,
constants.CMD_QUIT
]
})
return questions
}
const emitter = new eventEmitter()
var { Facebook } = require('fb')
var fb = new Facebook()
fb.setAccessToken(common.env('ACCESS_TOKEN'))
function main () {
inquirer.prompt(createQuestions()).then(answers => {
switch (answers.cmd) {
case constants.CMD_INITIALIZE:
initialize(fb, emitter)
break
case constants.CMD_AUTHENTICATE:
authenticate(fb, emitter)
break
case constants.CMD_PHOTO:
photo(fb)
break
case constants.CMD_VIDEO:
video(fb)
break
case constants.CMD_QUIT:
process.exit()
}
})
}
main()