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 ( ) => {
88console . 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` )
1111if ( stderr ) {
1212console . error ( stderr )
1313throw new Error ( 'Error stashing files' )
@@ -20,7 +20,7 @@ const cherryPickCommit = async (commit: string, count = 0): Promise<void> => {
2020return
2121}
2222try {
23- const { stdout} = await exec ( `git cherry-pick${ commit } ` )
23+ const { stdout} = await node . exec ( `git cherry-pick${ commit } ` )
2424if ( ! stdout ) {
2525throw 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 > {
5151const { 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 } '` )
5353if ( stderr ) {
5454console . error ( stderr )
5555throw 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 > {
6161try {
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' )
6464if ( ! stderr ) {
6565return
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' )
7676if ( ! stderr ) {
7777const match = stdout . match ( / ^ g i t v e r s i o n ( \d + \. ) ? ( \d + \. ) ? ( \* | \d + ) / )
7878if ( 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' )
8989if ( stderr ) {
9090throw new Error ( 'Error initializing Gits' )
9191}
@@ -98,14 +98,14 @@ export async function initIfNotExists(): Promise<void> {
9898throw new Error ( 'Git must be installed' )
9999}
100100
101- const hasGitInit = exists ( '.git' )
101+ const hasGitInit = node . exists ( '.git' )
102102if ( ! hasGitInit ) {
103103await 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 } ` )
109109if ( stderr ) {
110110const alreadyExists = stderr . match ( `${ gitOrigin } already exists.` )
111111const successfulNewBranch = stderr . match ( 'new branch' )
@@ -120,7 +120,7 @@ export async function addRemote(repo: string): Promise<void> {
120120
121121export async function checkRemoteExists ( ) :Promise < boolean > {
122122try {
123- const { stdout, stderr} = await exec ( 'git remote -v' )
123+ const { stdout, stderr} = await node . exec ( 'git remote -v' )
124124if ( stderr ) {
125125return false
126126}