Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite1bb7a4

Browse files
committed
Add error logs + WIP: fux submodule bug
1 parentde6b22c commite1bb7a4

File tree

1 file changed

+36
-37
lines changed

1 file changed

+36
-37
lines changed

‎src/parse.js

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,29 @@ function parseContent(md) {
8484

8585
functionrmDir(dir,rmSelf){
8686

87-
letfiles;
88-
rmSelf=(rmSelf===undefined) ?true :rmSelf;
89-
// dir = dir + path.sep;
90-
91-
try{files=fs.readdirSync(dir);}catch(e){console.log(`Sorry, directory '${dir}' doesn't exist.`);return;}
92-
93-
if(files.length>0){
94-
files.forEach(function(x,i){
95-
if(fs.statSync(path.join(dir,x)).isDirectory()){
96-
rmDir(path.join(dir,x));
97-
}else{
98-
fs.unlinkSync(path.join(dir,x));
99-
}
100-
});
101-
}
87+
try{
88+
letfiles;
89+
rmSelf=(rmSelf===undefined) ?true :rmSelf;
10290

103-
if(rmSelf){
104-
// check if user want to delete the directory ir just the files in this directory
105-
fs.rmdirSync(dir);
106-
}
91+
try{files=fs.readdirSync(dir);}catch(e){console.log(`Sorry, directory '${dir}' doesn't exist.`);return;}
92+
93+
if(files.length>0){
94+
files.forEach(function(x,i){
95+
if(fs.statSync(path.join(dir,x)).isDirectory()){
96+
rmDir(path.join(dir,x));
97+
}else{
98+
fs.unlinkSync(path.join(dir,x));
99+
}
100+
});
101+
}
107102

103+
if(rmSelf){
104+
// check if user want to delete the directory ir just the files in this directory
105+
fs.rmdirSync(dir);
106+
}
107+
}catch(error){
108+
returnerror;
109+
}
108110
}
109111

110112
asyncfunctioncleanupFiles(workingDir){
@@ -118,9 +120,8 @@ async function cleanupFiles(workingDir) {
118120
rmDir(path.join(process.cwd(),'.git','modules',workingDir));
119121
rmDir(workingDir);
120122

121-
returntrue;
122123
}catch(error){
123-
returnfalse;
124+
returnerror;
124125
}
125126
}
126127

@@ -144,27 +145,18 @@ async function build({ repo, codeBranch, setupBranch, isLocal }) {
144145
else{
145146
constgitTest=simpleGit(process.cwd());
146147
constisRepo=awaitgitTest.checkIsRepo();
148+
localPath=path.join(process.cwd(),workingDir);
147149

148150
if(isRepo){
149-
conststartCleanup=cleanupFiles(workingDir);
150-
151-
if(startCleanup){
152-
console.log('Clenned old files from git module...');
153-
}
154-
155151
awaitgitTest.submoduleAdd(repo,workingDir);
156152

157-
git=simpleGit(path.join(process.cwd(),workingDir));
158-
159153
isSubModule=true;
160-
localPath=path.join(process.cwd(),workingDir);
161-
162154
}
163155
else{
164-
awaitgitTest.clone(repo);
165-
git=simpleGit(process.cwd());
166-
localPath=process.cwd();
156+
awaitgitTest.clone(repo,localPath);
167157
}
158+
159+
git=simpleGit(localPath);
168160
}
169161

170162
awaitgit.fetch();
@@ -238,10 +230,17 @@ async function build({ repo, codeBranch, setupBranch, isLocal }) {
238230

239231
// cleanup the submodules
240232
if(!isLocal){
241-
constendCleanup=awaitcleanupFiles(workingDir);
233+
letcleanupErr;
234+
235+
if(isSubModule){
236+
cleanupErr=awaitcleanupFiles(workingDir);
237+
}
238+
else{
239+
cleanupErr=rmDir(path.join(process.cwd(),workingDir));
240+
}
242241

243-
if(!endCleanup){
244-
console.log('Error when deletingthe git submodules');
242+
if(!cleanupErr){
243+
console.log(`Error when deletingtemporary files on${isSubModule ?'module' :'folder'}${workingDir}.`);
245244
}
246245
}
247246

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp