UNPKG

582 BJavaScriptView Raw
1"use strict";
2
3const log = require("npmlog");
4const childProcess = require("@lerna/child-process");
5
6module.exports.remoteBranchExists = remoteBranchExists;
7
8/**
9 * @param {string} gitRemote
10 * @param {string} branch
11 * @param {import("@lerna/child-process").ExecOpts} opts
12 */
13function remoteBranchExists(gitRemote, branch, opts) {
14 log.silly("remoteBranchExists");
15
16 const remoteBranch = `${gitRemote}/${branch}`;
17
18 try {
19 childProcess.execSync("git", ["show-ref", "--verify", `refs/remotes/${remoteBranch}`], opts);
20 return true;
21 } catch (e) {
22 return false;
23 }
24}