/**
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
 */ import { spawnSync , SpawnSyncReturns } from 'child_process' ; export class GitClient { constructor ( public projectDir , public remoteGitUrl ) { } spawnGitProcess ( args , printStderr = true ) { return spawnSync ( 'git' , args , { cwd : this . projectDir , stdio : [ 'pipe' , 'pipe' , printStderr ? 'inherit' : 'pipe' ] , encoding : 'utf8' } ) ; } clone ( ) { this . spawnGitProcess ( [ 'clone' , this . remoteGitUrl , '.' , '--depth=1' ] ) ; } stageAllChanges ( ) { return this . spawnGitProcess ( [ 'add' , '-A' ] ) . status === 0 ; } createNewCommit ( message ) { return this . spawnGitProcess ( [ 'commit' , '--no-verify' , '-m' , message ] ) . status === 0 ; } checkoutNewBranch ( branchName ) { return this . spawnGitProcess ( [ 'checkout' , '-b' , branchName ] ) . status === 0 ; } pushBranchToRemote ( branchName , force = false , remoteName = this . remoteGitUrl ) { return this . spawnGitProcess ( [ 'push' , remoteName , branchName , `${ force && '-f' }` ] ) . status === 0 ; } }