11import * as CR from 'typings'
2- import { exec , exists } from '../node'
2+ import node from '../node'
33
44
55const gitOrigin = 'coderoad'
66
77const stashAllFiles = async ( ) => {
88 console . log ( 'stashAllFiles' )
99 // stash files including untracked (eg. newly created file)
10- const { stdout, stderr} = await exec ( `git stash --include-untracked` )
10+ const { stdout, stderr} = await node . exec ( `git stash --include-untracked` )
1111 if ( stderr ) {
1212 console . error ( stderr )
1313 throw new Error ( 'Error stashing files' )
@@ -20,7 +20,7 @@ const cherryPickCommit = async (commit: string, count = 0): Promise<void> => {
2020 return
2121 }
2222 try {
23- const { stdout} = await exec ( `git cherry-pick ${ commit } ` )
23+ const { stdout} = await node . exec ( `git cherry-pick ${ commit } ` )
2424 if ( ! stdout ) {
2525 throw new Error ( 'No cherry-pick output' )
2626 }
@@ -49,7 +49,7 @@ export function loadCommit(commit: string): Promise<void> {
4949
5050export async function saveCommit ( position : CR . Position ) : Promise < void > {
5151 const { levelId, stageId, stepId} = position
52- const { stdout, stderr} = await exec ( `git commit -am 'completed ${ levelId } /${ stageId } /${ stepId } '` )
52+ const { stdout, stderr} = await node . exec ( `git commit -am 'completed ${ levelId } /${ stageId } /${ stepId } '` )
5353 if ( stderr ) {
5454 console . error ( stderr )
5555 throw new Error ( 'Error saving progress to Git' )
@@ -60,7 +60,7 @@ export async function saveCommit(position: CR.Position): Promise<void> {
6060export async function clear ( ) : Promise < void > {
6161 try {
6262 // commit progress to git
63- const { stderr} = await exec ( 'git reset HEAD --hard && git clean -fd' )
63+ const { stderr} = await node . exec ( 'git reset HEAD --hard && git clean -fd' )
6464 if ( ! stderr ) {
6565 return
6666 }
@@ -72,7 +72,7 @@ export async function clear(): Promise<void> {
7272}
7373
7474export async function version ( ) : Promise < string | boolean > {
75- const { stdout, stderr} = await exec ( 'git --version' )
75+ const { stdout, stderr} = await node . exec ( 'git --version' )
7676 if ( ! stderr ) {
7777 const match = stdout . match ( / ^ g i t v e r s i o n ( \d + \. ) ? ( \d + \. ) ? ( \* | \d + ) / )
7878 if ( match ) {
@@ -85,7 +85,7 @@ export async function version(): Promise<string | boolean> {
8585}
8686
8787async function init ( ) : Promise < void > {
88- const { stderr} = await exec ( 'git init' )
88+ const { stderr} = await node . exec ( 'git init' )
8989 if ( stderr ) {
9090 throw new Error ( 'Error initializing Gits' )
9191 }
@@ -98,14 +98,14 @@ export async function initIfNotExists(): Promise<void> {
9898 throw new Error ( 'Git must be installed' )
9999 }
100100
101- const hasGitInit = exists ( '.git' )
101+ const hasGitInit = node . exists ( '.git' )
102102 if ( ! hasGitInit ) {
103103 await init ( )
104104 }
105105}
106106
107107export async function addRemote ( repo : string ) : Promise < void > {
108- const { stderr} = await exec ( `git remote add ${ gitOrigin } ${ repo } && git fetch ${ gitOrigin } ` )
108+ const { stderr} = await node . exec ( `git remote add ${ gitOrigin } ${ repo } && git fetch ${ gitOrigin } ` )
109109 if ( stderr ) {
110110 const alreadyExists = stderr . match ( `${ gitOrigin } already exists.` )
111111 const successfulNewBranch = stderr . match ( 'new branch' )
@@ -120,7 +120,7 @@ export async function addRemote(repo: string): Promise<void> {
120120
121121export async function checkRemoteExists ( ) : Promise < boolean > {
122122 try {
123- const { stdout, stderr} = await exec ( 'git remote -v' )
123+ const { stdout, stderr} = await node . exec ( 'git remote -v' )
124124 if ( stderr ) {
125125 return false
126126 }
0 commit comments