Dont auto-publish on PR's

master
Futago-za Ryuu 5 years ago
parent 42a6f774fb
commit 910a51bf5f

@ -53,5 +53,6 @@ jobs:
displayName: 'Build "pegjs/dist/*.js" files' displayName: 'Build "pegjs/dist/*.js" files'
- script: node tools/publish-dev - script: node tools/publish-dev
displayName: 'Publish to NPM' displayName: 'Publish to NPM'
env: variables:
NPM_TOKEN: $(NPM_CI_TOKEN) NPM_TOKEN: $(NPM_CI_TOKEN)
PR_BRANCH: $[ coalesce(variables['System.PullRequest.SourceBranch'], 'not-found') ]

@ -14,9 +14,17 @@ const npmrc = path.join( pegjs, ".npmrc" );
// variabes // variabes
const APP = require( "./package.json" ).name; const APP = require( "./package.json" ).name;
const { GIT_BRANCH, GIT_COMMIT_SHA, NPM_TOKEN } = process.env;
const VERSION = require( packagejson ).version; const VERSION = require( packagejson ).version;
const {
GIT_BRANCH,
GIT_COMMIT_SHA,
NPM_TOKEN,
PR_BRANCH,
} = process.env;
// local helpers // local helpers
function die( err ) { function die( err ) {
@ -39,6 +47,13 @@ function exec( command, print = true ) {
// assertions // assertions
if ( PR_BRANCH !== "not-found" ) {
console.log( "Skipping publish, PR's are not published." );
process.exit( 0 );
}
if ( ! GIT_BRANCH ) die( "`process.env.GIT_BRANCH` is required by " + APP ); if ( ! GIT_BRANCH ) die( "`process.env.GIT_BRANCH` is required by " + APP );
if ( ! NPM_TOKEN ) die( "`process.env.NPM_TOKEN` is required by " + APP ); if ( ! NPM_TOKEN ) die( "`process.env.NPM_TOKEN` is required by " + APP );

Loading…
Cancel
Save