diff --git a/grunt/aliases.yaml b/grunt/aliases.yaml index 5772bb3..9ed3e23 100644 --- a/grunt/aliases.yaml +++ b/grunt/aliases.yaml @@ -69,6 +69,7 @@ pushSite: # Provide all Front-End service files plus CSS styling for CMS needs, copy it to separate branch "css" and push it to remote git server. # ================================== pushCss: + - 'checkMaster' #task helper #Dev - 'dev' #task helper #Postcss autoprefixer @@ -84,6 +85,7 @@ pushCss: # Provide all Front-End service files plus LESS styling for CMS needs, copy it to separate branch "less" and push it to remote git server. # ================================== pushLess: + - 'checkMaster' #task helper #Dev - 'dev' #task helper #Less @@ -138,5 +140,12 @@ pushLessBranch: - 'buildcontrol:less' - 'notify:less' +# check is local master branch synced with remote master +checkMaster: + # check Is Master + - 'shell:isMaster' + # check is Updated + - 'shell:isUpdated' + # ================================== # ================================== diff --git a/grunt/shell.js b/grunt/shell.js new file mode 100644 index 0000000..47be042 --- /dev/null +++ b/grunt/shell.js @@ -0,0 +1,55 @@ +function isMaster(err, stdout, stderr, cb) { + if (err) { + cb(err); + return; + } + var match = stdout.match(/\n/i); + stdout = stdout.slice(0, match.index); + if (stdout === 'master') { + cb(); + return; + } else { + console.log('You are not at master brunch!'); + console.log('Please switch to master branch and start script again.'); + cb(); + process.exit(); + } +} +function isUpdated(err, stdout, stderr, cb) { + if (err) { + cb(err); + return; + } + var match = stdout.match(/\n/i); + stdout = stdout.slice(0, match.index); + var matchAhead = stdout.match(/ahead/i); + if (!matchAhead) { + cb(); + return; + } else { + console.log('Error!'); + console.log('Your local master branch is not synchronized with remote master.'); + console.log('Please push you changes to remote repo (git push), and start script again.'); + cb(); + process.exit(); + } +} + +module.exports = { + isMaster: { + command: 'git rev-parse --abbrev-ref HEAD', + options: { + stderr: false, + stdout: false, + callback: isMaster + } + }, + isUpdated: { + command: 'git status -sb', + options: { + stderr: false, + stdout: false, + callback: isUpdated + } + } +};