@@ -110,12 +110,12 @@ function rmDir(dir, rmSelf) {
110
110
async function cleanupFiles ( workingDir ) {
111
111
112
112
try {
113
- const gitModule = simpleGit ( __dirname ) ;
113
+ const gitModule = simpleGit ( process . cwd ( ) ) ;
114
114
115
115
await gitModule . subModule ( [ 'deinit' , '-f' , workingDir ] ) ;
116
116
await gitModule . rm ( workingDir ) ;
117
117
await gitModule . reset ( [ 'HEAD' ] ) ;
118
- rmDir ( path . join ( __dirname , '.git' , 'modules' , workingDir ) ) ;
118
+ rmDir ( path . join ( process . cwd ( ) , '.git' , 'modules' , workingDir ) ) ;
119
119
rmDir ( workingDir ) ;
120
120
121
121
return true ;
@@ -135,12 +135,14 @@ async function build({ repo, codeBranch, setupBranch, isLocal }) {
135
135
136
136
let git ;
137
137
let isSubModule = false ;
138
+ let localPath ;
138
139
139
140
if ( isLocal ) {
140
141
git = simpleGit ( repo ) ;
142
+ localPath = repo ;
141
143
}
142
144
else {
143
- const gitTest = simpleGit ( __dirname ) ;
145
+ const gitTest = simpleGit ( process . cwd ( ) ) ;
144
146
const isRepo = await gitTest . checkIsRepo ( ) ;
145
147
146
148
if ( isRepo ) {
@@ -152,14 +154,16 @@ async function build({ repo, codeBranch, setupBranch, isLocal }) {
152
154
153
155
await gitTest . submoduleAdd ( repo , workingDir ) ;
154
156
155
- git = simpleGit ( path . join ( __dirname , workingDir ) ) ;
157
+ git = simpleGit ( path . join ( process . cwd ( ) , workingDir ) ) ;
156
158
157
159
isSubModule = true ;
160
+ localPath = path . join ( process . cwd ( ) , workingDir ) ;
158
161
159
162
}
160
163
else {
161
164
await gitTest . clone ( repo ) ;
162
- git = simpleGit ( __dirname ) ;
165
+ git = simpleGit ( process . cwd ( ) ) ;
166
+ localPath = process . cwd ( ) ;
163
167
}
164
168
}
165
169
@@ -169,8 +173,8 @@ async function build({ repo, codeBranch, setupBranch, isLocal }) {
169
173
await git . checkout ( setupBranch ) ;
170
174
171
175
// Load files
172
- const _mdContent = fs . readFileSync ( path . join ( __dirname , workingDir , 'TUTORIAL.md' ) , 'utf8' ) ;
173
- let _config = fs . readFileSync ( path . join ( __dirname , workingDir , 'coderoad.yaml' ) , 'utf8' ) ;
176
+ const _mdContent = fs . readFileSync ( path . join ( localPath , 'TUTORIAL.md' ) , 'utf8' ) ;
177
+ let _config = fs . readFileSync ( path . join ( localPath , 'coderoad.yaml' ) , 'utf8' ) ;
174
178
175
179
// Add one more line to the content as per Shawn's request
176
180
const mdContent = parseContent ( _mdContent ) ;