UNPKG

@daiyu-5577/quickbuild

Version:

front-end build service

31 lines (30 loc) 1.58 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { execPms } from "./exec.js"; export function checkBaranch(branchName, cwd) { return __awaiter(this, void 0, void 0, function* () { const localBranchesResult = yield execPms('git branch', { cwd, encoding: 'utf-8' }); const localBranches = localBranchesResult.stdout.split('\n'); const localBranchExists = localBranches.some(v => v.includes(branchName)); if (localBranchExists) { yield execPms(`git checkout ${branchName}`, { cwd, encoding: 'utf-8' }); } else { yield execPms(`git checkout -b ${branchName} origin/${branchName}`, { cwd, encoding: 'utf-8' }); } yield execPms(`git pull`, { cwd }); }); } export function gitClean(cwd) { return __awaiter(this, void 0, void 0, function* () { yield execPms(`git checkout .`, { cwd }); yield execPms(`git clean -df`, { cwd }); }); }