mirror of
https://github.com/zhigang1992/firebase-tools.git
synced 2026-06-14 01:34:54 +08:00
* format and lint scripts * allow ecma 2017 format (async/await in Node 8) * format and fix scripts directory
53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
"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-tools/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 CLI is available. Release notes: ${getUrl(version)}` },
|
|
(err) => {
|
|
if (err) {
|
|
console.error(err);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
);
|