Skip to content

Commit 2392166

Browse files
EnixCodaebidel
authored andcommitted
fix #6 (#16)
1 parent 0a60a54 commit 2392166

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crawlsite.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ function slugify(str) {
5656

5757
function mkdirSync(dirPath) {
5858
try {
59-
fs.mkdirSync(dirPath);
59+
dirPath.split('/').reduce((parentPath, dirName) => {
60+
const currentPath = parentPath + dirName;
61+
if (!fs.existsSync(currentPath)) {
62+
fs.mkdirSync(currentPath);
63+
}
64+
return currentPath + '/';
65+
}, '');
6066
} catch (err) {
6167
if (err.code !== 'EEXIST') {
6268
throw err;

0 commit comments

Comments
 (0)