build.js
function ensureNoChangesOnMasterBeforePublish() {
    //Let users try the build script as long as they're not doing an actual publish
    if (!SHOULD_PUBLISH) {
        return true;
    }

    shell.exec("git fetch origin", {silent: true});

    const currentBranch = shell.exec("git symbolic-ref --short -q HEAD", {silent: true});
    if (currentBranch.stdout.trim() !== "master") {
        shell.echo("Modules can only be deployed off 'master' branch.");
        shell.exit(-1);
    }

    const changesOnBranch = shell.exec("git log HEAD..origin/master --oneline", {silent: true});
    if (changesOnBranch.stdout.trim() !== "") {
        shell.echo("Local repo and origin are out of sync! Have you pushed all your changes? Have you pulled the latest?");
        shell.exit(-1);
    }

    const localChanges = shell.exec("git status --porcelain", {silent: true});
    if (localChanges.stdout.trim() !== "") {
        shell.echo("This git repository is has uncommitted files. Publish aborted!");
        shell.exit(-1);
    }
}
function ensureNoChangesOnMasterBeforePublish() {
    //Let users try the build script as long as they're not doing an actual publish
    if (!SHOULD_PUBLISH) {
        return true;
    }

    shell.exec("git fetch origin", {silent: true});

    const currentBranch = shell.exec("git symbolic-ref --short -q HEAD", {silent: true});
    if (currentBranch.stdout.trim() !== "master") {
        shell.echo("Modules can only be deployed off 'master' branch.");
        shell.exit(-1);
    }

    const changesOnBranch = shell.exec("git log HEAD..origin/master --oneline", {silent: true});
    if (changesOnBranch.stdout.trim() !== "") {
        shell.echo("Local repo and origin are out of sync! Have you pushed all your changes? Have you pulled the latest?");
        shell.exit(-1);
    }

    const localChanges = shell.exec("git status --porcelain", {silent: true});
    if (localChanges.stdout.trim() !== "") {
        shell.echo("This git repository is has uncommitted files. Publish aborted!");
        shell.exit(-1);
    }
}
function ensureNoChangesOnMasterBeforePublish ( ) { //Let users try the build script as long as they're not doing an actual publish if ( ! SHOULD_PUBLISH ) { return true ; } shell . exec ( "git fetch origin" , { silent : true } ) ; const currentBranch = shell . exec ( "git symbolic-ref --short -q HEAD" , { silent : true } ) ; if ( currentBranch . stdout . trim ( ) !== "master" ) { shell . echo ( "Modules can only be deployed off 'master' branch." ) ; shell . exit ( - 1 ) ; } const changesOnBranch = shell . exec ( "git log HEAD..origin/master --oneline" , { silent : true } ) ; if ( changesOnBranch . stdout . trim ( ) !== "" ) { shell . echo ( "Local repo and origin are out of sync! Have you pushed all your changes? Have you pulled the latest?" ) ; shell . exit ( - 1 ) ; } const localChanges = shell . exec ( "git status --porcelain" , { silent : true } ) ; if ( localChanges . stdout . trim ( ) !== "" ) { shell . echo ( "This git repository is has uncommitted files. Publish aborted!" ) ; shell . exit ( - 1 ) ; } }
Ensure that we're in a pristine, up-to-date repo and on the master branch before allowing user to continue. Only does
verification if user is actually trying to perform an NPM publish
Ensure that we re in a pristine up - to - date repo and on the master branch before allowing user to continue . Only does verification if user is actually trying to perform an NPM publish