Allow saving github token to a file
This commit is contained in:
parent
9ad785c44e
commit
3c9ba130a0
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 _ = 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) {
|
||||||
|
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(`Environment variable ${colors.bold("CHANGELOG_TOKEN")} must be set.`);
|
||||||
|
log.error(`Alternative create ${colors.bold("scripts/github_token.txt")} file.`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (process.argv[2] === undefined) {
|
if (process.argv[2] === undefined) {
|
||||||
log.error(`Argument ${colors.bold("version")} is missing`);
|
log.error(`Argument ${colors.bold("version")} is missing`);
|
||||||
|
Loading…
Reference in New Issue
Block a user