aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2021-07-06 08:12:51 +1000
committerSam Potts <sam@potts.es>2021-07-06 08:12:51 +1000
commit3a01837561aaa315667b8bbd4dbff5bc56fb9e52 (patch)
tree6c5df4665d9b9ea0069db0c65a1849eaff592a54
parentba4bdb335adad492bbc457fa1ec8c0d6e66f1636 (diff)
downloadplyr-3a01837561aaa315667b8bbd4dbff5bc56fb9e52.tar.lz
plyr-3a01837561aaa315667b8bbd4dbff5bc56fb9e52.tar.xz
plyr-3a01837561aaa315667b8bbd4dbff5bc56fb9e52.zip
fix: allow local builds without git
-rw-r--r--tasks/deploy.js29
1 files changed, 17 insertions, 12 deletions
diff --git a/tasks/deploy.js b/tasks/deploy.js
index 5860f908..71e533e6 100644
--- a/tasks/deploy.js
+++ b/tasks/deploy.js
@@ -51,11 +51,19 @@ const paths = {
],
};
-// Get branch info
+// Get git branch info
+const currentBranch = (() => {
+ try {
+ return gitbranch.sync();
+ } catch (_) {
+ return null;
+ }
+})();
+
const branch = {
- current: gitbranch.sync(),
- master: 'master',
- beta: 'beta',
+ current: currentBranch,
+ isMaster: currentBranch === 'master',
+ isBeta: currentBranch === 'beta',
};
const maxAge = 31536000; // 1 year
@@ -66,7 +74,7 @@ const options = {
},
},
demo: {
- uploadPath: branch.current === branch.beta ? '/beta' : null,
+ uploadPath: branch.isBeta ? '/beta' : null,
headers: {
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
},
@@ -99,11 +107,8 @@ const renameFile = rename((p) => {
// Check we're on the correct branch to deploy
const canDeploy = () => {
- const allowed = [branch.master, branch.beta];
-
- if (!allowed.includes(branch.current)) {
- console.error(`Must be on ${allowed.join(', ')} to publish! (current: ${branch.current})`);
-
+ if (![branch.isMaster, branch.isBeta].some(Boolean)) {
+ console.error(`Must be on an allowed branch to publish! (current: ${branch.current})`);
return false;
}
@@ -195,7 +200,7 @@ gulp.task('demo', (done) => {
const error = `${paths.demo}error.html`;
const pages = [index];
- if (branch.current === branch.master) {
+ if (branch.isMaster) {
pages.push(error);
}
@@ -220,7 +225,7 @@ gulp.task('open', () => {
return gulp.src(__filename).pipe(
open({
- uri: `https://${domain}/${branch.current === branch.beta ? 'beta' : ''}`,
+ uri: `https://${domain}/${branch.isBeta ? 'beta' : ''}`,
}),
);
});