Skip to content

Commit 0fd57ba

Browse files
committed
tasks: sub fs.existsSync for fs.statSync
1 parent 262e90d commit 0fd57ba

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tasks/pretest.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,20 @@ fs.writeFile(constants.pathToSetPlotConfig, setPlotConfig, function(err) {
3838
});
3939

4040
// make artifact folders for image tests
41-
if(!fs.existsSync(constants.pathToTestImagesDiff)) {
41+
if(!doesDirExist(constants.pathToTestImagesDiff)) {
4242
fs.mkdirSync(constants.pathToTestImagesDiff);
4343
}
44-
if(!fs.existsSync(constants.pathToTestImages)) {
44+
if(!doesDirExist(constants.pathToTestImages)) {
4545
fs.mkdirSync(constants.pathToTestImages);
4646
}
47+
48+
function doesDirExist(dirPath) {
49+
try {
50+
if(fs.statSync(dirPath).isDirectory()) return true;
51+
}
52+
catch(e) {
53+
return false;
54+
}
55+
56+
return false;
57+
}

0 commit comments

Comments
 (0)