UNPKG

669 BJavaScriptView Raw
1const { exec } = require('child_process')
2
3module.exports = function(targetBranch) {
4 return new Promise((resolve, reject) => {
5 exec('git symbolic-ref --short -q HEAD', (err, stdout, stderr) => {
6 const currentBranch = stdout.replace(/\s/g, '')
7 if (targetBranch) {
8 isBranchCorrect = currentBranch === targetBranch
9 } else {
10 isBranchCorrect = currentBranch === 'master'
11 }
12 if (!isBranchCorrect) {
13 console.error('请在 master 分支打包')
14 process.exit(0)
15 } else {
16 resolve()
17 }
18 })
19 })
20}