-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
35 lines (28 loc) · 838 Bytes
/
cli.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
#!/usr/bin/env node
const chalk = require('chalk')
const fn = require('./lib/functions')
const exec = require('child_process').execSync
// Parse arguments
let args = process.argv.splice(2, process.argv.length)
const DEBUG = process.argv.indexOf('--debug') >= 0
args = args.filter(arg => arg !== '--debug')
if (args.length === 0) {
console.log('No command specified.')
process.exit(0)
}
let CMD = args.shift()
// Process commands
switch (CMD.trim().toLowerCase()) {
case 'configure':
fn.configure(DEBUG)
return
case 'setup':
fn.setup()
return
case 'deploy':
console.log(chalk.magenta(`\n\nConfiguring environment variables...`))
fn.configure(DEBUG)
console.log(chalk.magenta(`\n\nDeploying cloud functions...`))
console.log(chalk.gray(exec('firebase deploy --only functions')))
return
}