mirror of
https://github.com/thelounge/thelounge
synced 2024-11-10 06:34:21 +00:00
Allow saving github token to a file
This commit is contained in:
parent
9ad785c44e
commit
3c9ba130a0
2 changed files with 14 additions and 4 deletions
1
scripts/.gitignore
vendored
Normal file
1
scripts/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
github_token.txt
|
|
@ -48,24 +48,33 @@ node scripts/changelog <version>
|
||||||
const _ = require("lodash");
|
const _ = require("lodash");
|
||||||
const colors = require("chalk");
|
const colors = require("chalk");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
const GraphQLClient = require("graphql-request").GraphQLClient;
|
const GraphQLClient = require("graphql-request").GraphQLClient;
|
||||||
const moment = require("moment");
|
const moment = require("moment");
|
||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
const log = require("../src/log");
|
const log = require("../src/log");
|
||||||
const packageJson = require("../package.json");
|
const packageJson = require("../package.json");
|
||||||
const token = process.env.CHANGELOG_TOKEN;
|
let token = process.env.CHANGELOG_TOKEN;
|
||||||
|
|
||||||
const readFile = util.promisify(fs.readFile);
|
const readFile = util.promisify(fs.readFile);
|
||||||
const writeFile = util.promisify(fs.writeFile);
|
const writeFile = util.promisify(fs.writeFile);
|
||||||
|
|
||||||
const changelogPath = "./CHANGELOG.md";
|
const changelogPath = path.resolve(__dirname, "..", "CHANGELOG.md");
|
||||||
|
|
||||||
// CLI argument validations
|
// CLI argument validations
|
||||||
|
|
||||||
if (token === undefined) {
|
if (token === undefined) {
|
||||||
log.error(`Environment variable ${colors.bold("CHANGELOG_TOKEN")} must be set.`);
|
try {
|
||||||
process.exit(1);
|
token = fs
|
||||||
|
.readFileSync(path.resolve(__dirname, "./github_token.txt"))
|
||||||
|
.toString()
|
||||||
|
.trim();
|
||||||
|
} catch (e) {
|
||||||
|
log.error(`Environment variable ${colors.bold("CHANGELOG_TOKEN")} must be set.`);
|
||||||
|
log.error(`Alternative create ${colors.bold("scripts/github_token.txt")} file.`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.argv[2] === undefined) {
|
if (process.argv[2] === undefined) {
|
||||||
|
|
Loading…
Reference in a new issue