mirror of
https://github.com/thelounge/thelounge
synced 2024-11-21 19:43:07 +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,25 +48,34 @@ node scripts/changelog <version>
|
|||
const _ = require("lodash");
|
||||
const colors = require("chalk");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const GraphQLClient = require("graphql-request").GraphQLClient;
|
||||
const moment = require("moment");
|
||||
const semver = require("semver");
|
||||
const util = require("util");
|
||||
const log = require("../src/log");
|
||||
const packageJson = require("../package.json");
|
||||
const token = process.env.CHANGELOG_TOKEN;
|
||||
let token = process.env.CHANGELOG_TOKEN;
|
||||
|
||||
const readFile = util.promisify(fs.readFile);
|
||||
const writeFile = util.promisify(fs.writeFile);
|
||||
|
||||
const changelogPath = "./CHANGELOG.md";
|
||||
const changelogPath = path.resolve(__dirname, "..", "CHANGELOG.md");
|
||||
|
||||
// CLI argument validations
|
||||
|
||||
if (token === undefined) {
|
||||
try {
|
||||
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) {
|
||||
log.error(`Argument ${colors.bold("version")} is missing`);
|
||||
|
|
Loading…
Reference in a new issue