-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.js
30 lines (27 loc) · 914 Bytes
/
run.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
/* eslint-disable no-console */
const firebase = require('firebase-tools');
const tasks = new Map(); // The collection of automation tasks ('build', 'publish', etc.)
function run(task) {
const start = new Date();
console.log(`${'\x1b[32m'}Starting "${task}"...${'\x1b[0m'}`);
return Promise.resolve()
.then(() => tasks.get(task)())
.then(
() => {
console.log(
`${'\x1b[32m'}Finished "${task}" after ${
new Date().getTime() - start.getTime()
}ms${'\x1b[0m'}`,
);
},
err => console.error(err.stack),
);
}
tasks.set('deploy', async () => {
return Promise.resolve()
.then(() => firebase.login({ nonInteractive: false }))
.then(() => firebase.deploy())
.then(() => console.log('Deployed to Firebase'));
});
// Execute the specified task. E.g.: node run build
run(/^\w/.test(process.argv[2] || '') && process.argv[2]);