Skip to content

Commit

Permalink
Update: avoid unnecessary checks for environment variables (#29)
Browse files Browse the repository at this point in the history
Currently, eslint-release requires `NPM_TOKEN` and `ESLINT_GITHUB_TOKEN` environment variables to be present when generating a release in addition to publishing a release. However, the tokens aren't necessary when generating a release, and requiring them makes it more difficult to test-generate a release locally. With this commit, the tokens are only validated when publishing, not when generating.
  • Loading branch information
not-an-aardvark committed Oct 17, 2018
1 parent 5c5c361 commit 34d6f55
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/release-ops.js
Expand Up @@ -62,8 +62,13 @@ function validateSetup() {
console.error("The 'repository' field must be in the format 'foo/bar' in package.json");
ShellOps.exit(1);
}
}

// check NPM_TOKEN
/**
* Verify that the appropriate credentials are present before publishing a release
* @returns {void}
*/
function validateEnvironment() {
if (!process.env.NPM_TOKEN) {
console.error("Missing NPM_TOKEN environment variable");
ShellOps.exit(1);
Expand Down Expand Up @@ -357,6 +362,7 @@ function publishReleaseToGitHub(releaseInfo) {
*/
function publishRelease() {
validateSetup();
validateEnvironment();
var releaseInfo = JSON.parse(fs.readFileSync(".eslint-release-info.json", "utf8"));

var oldNpmrcContents;
Expand Down

0 comments on commit 34d6f55

Please sign in to comment.