INNER CODE UNIT · JavaScript
mkdirSync
puppeteer/examples · crawlsite.js:57
function mkdirSync(dirPath) {
try {
dirPath.split('/').reduce((parentPath, dirName) => {
const currentPath = parentPath + dirName;
if (!fs.existsSync(currentPath)) {
fs.mkdirSync(currentPath);
}
return currentPath + '/';
}, '');
} catch (err) {
if (err.code !== 'EEXIST') {
throw err;
}
}
}
/**
* Finds all anchors on the page, inclusive of those within shadow roots.