aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-06-02 04:55:40 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-06-02 04:55:40 +0800
commitd4d03f3d7f437d4199dcfec58cbd98735e5e7d51 (patch)
tree965218c799d79d0df33a3a03972984c139e700c9 /packages/monorepo-scripts/src
parent2f8e52f9057b98b5f60dc3ec3428b024739a2997 (diff)
downloaddexon-sol-tools-d4d03f3d7f437d4199dcfec58cbd98735e5e7d51.tar
dexon-sol-tools-d4d03f3d7f437d4199dcfec58cbd98735e5e7d51.tar.gz
dexon-sol-tools-d4d03f3d7f437d4199dcfec58cbd98735e5e7d51.tar.bz2
dexon-sol-tools-d4d03f3d7f437d4199dcfec58cbd98735e5e7d51.tar.lz
dexon-sol-tools-d4d03f3d7f437d4199dcfec58cbd98735e5e7d51.tar.xz
dexon-sol-tools-d4d03f3d7f437d4199dcfec58cbd98735e5e7d51.tar.zst
dexon-sol-tools-d4d03f3d7f437d4199dcfec58cbd98735e5e7d51.zip
Check that git branch is up to date before publishing
Diffstat (limited to 'packages/monorepo-scripts/src')
-rw-r--r--packages/monorepo-scripts/src/prepublish_checks.ts18
1 files changed, 17 insertions, 1 deletions
diff --git a/packages/monorepo-scripts/src/prepublish_checks.ts b/packages/monorepo-scripts/src/prepublish_checks.ts
index ae58524f5..2c096d8f6 100644
--- a/packages/monorepo-scripts/src/prepublish_checks.ts
+++ b/packages/monorepo-scripts/src/prepublish_checks.ts
@@ -47,9 +47,25 @@ async function checkPublishRequiredSetupAsync(): Promise<void> {
} catch (err) {
throw new Error('You must setup your AWS credentials by running `aws configure`. Do this and try again.');
}
+
+ utils.log('Checking that git branch is up to date with upstream...');
+ await execAsync('git fetch');
+ const res = await execAsync('git status -bs'); // s - short format, b - branch info
+ /**
+ * Possible outcomes
+ * ## branch_name...origin/branch_name [behind n]
+ * ## branch_name...origin/branch_name [ahead n]
+ * ## branch_name...origin/branch_name
+ */
+ const gitShortStatusHeader = res.stdout.split('\n')[0];
+ if (gitShortStatusHeader.includes('behind')) {
+ throw new Error('Your branch is behind upstream. Please pull before publishing.');
+ } else if (gitShortStatusHeader.includes('ahead')) {
+ throw new Error('Your branch is ahead of upstream. Please push before publishing.');
+ }
}
checkPublishRequiredSetupAsync().catch(err => {
- utils.log(err);
+ utils.log(err.message);
process.exit(1);
});