-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathtweet.js
51 lines (42 loc) · 1.09 KB
/
tweet.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
"use strict";
const fs = require("fs");
const Twitter = require("twitter");
function printUsage() {
console.error(
`
Usage: tweet.js <version>
Credentials must be stored in "twitter.json" in this directory.
Arguments:
- version: Version of module that was released. e.g. "1.2.3"
`
);
process.exit(1);
}
function getUrl(version) {
return `https://github.com/firebase/firebase-functions-test/releases/tag/v${version}`;
}
if (process.argv.length !== 3) {
console.error("Missing arguments.");
printUsage();
}
const version = process.argv.pop();
if (!version.match(/^\d+\.\d+\.\d+$/)) {
console.error(`Version "${version}" not a version number.`);
printUsage();
}
if (!fs.existsSync(`${__dirname}/twitter.json`)) {
console.error("Missing credentials.");
printUsage();
}
const creds = require("./twitter.json");
const client = new Twitter(creds);
client.post(
"statuses/update",
{ status: `v${version} of @Firebase Test SDK for Cloud Functions is available. Release notes: ${getUrl(version)}` },
(err) => {
if (err) {
console.error(err);
process.exit(1);
}
}
);