From 56cfdd9ab67d2a2e1a1316eee4c18c7a9cdda8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 20 Sep 2016 17:07:38 -0400 Subject: [PATCH] Only use precommit and prepush hooks when working on develop branch. This should solve @iconexperience's troubles outlined in https://github.com/paperjs/paper.js/issues/1116#issuecomment-244037792 --- .travis.yml | 2 +- gulp/utils/options.js | 10 +++++++++- package.json | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc943b55..694e742f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ install: before_script: - travis/setup-git.sh - npm set progress=false -- which gulp || npm install -g gulp +- which gulp || npm install -g gulp-cli - npm install script: - gulp jshint diff --git a/gulp/utils/options.js b/gulp/utils/options.js index bfd3763e..013efde9 100644 --- a/gulp/utils/options.js +++ b/gulp/utils/options.js @@ -13,7 +13,8 @@ var execSync = require('child_process').execSync, // Require the __options object, so we have access to the version number and // make amendments, e.g. the release date. - options = require('../../src/options.js'); + options = require('../../src/options.js'), + argv = require('minimist')(process.argv.slice(2)); function git(command) { return execSync('git ' + command).toString().trim(); @@ -22,6 +23,13 @@ function git(command) { options.date = git('log -1 --pretty=format:%ad'); options.branch = git('rev-parse --abbrev-ref HEAD'); +// If a specific branch is requested, quit without errors if we don't match. +if (argv.branch && argv.branch !== options.branch) { + console.log('Branch "' + options.branch + '" does not match "' + + argv.branch + '". There is nothing to do here.'); + process.exit(0); +} + // Get the date of the last commit from this branch for release date: var version = options.version, branch = options.branch; diff --git a/package.json b/package.json index ac7e3d73..6acdbb14 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ ], "main": "dist/paper-full.js", "scripts": { - "precommit": "gulp jshint", - "prepush": "gulp test", + "precommit": "gulp jshint --branch develop", + "prepush": "gulp test --branch develop", "build": "gulp build", "dist": "gulp dist", "zip": "gulp zip", @@ -66,6 +66,7 @@ "jshint": "^2.9.2", "jshint-summary": "^0.4.0", "merge-stream": "^1.0.0", + "minimist": "^1.2.0", "prepro": "^2.4.0", "qunitjs": "^1.23.0", "require-dir": "^0.3.0",