-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CHORE] check if local master branch synced with remote, before push …
…to less/css branches
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
}; |