diff --git a/client/plugins/fcc-create-nav-data/create-navigation-node.js b/client/plugins/fcc-create-nav-data/create-navigation-node.js index b2e1617f33..b6ba69c520 100644 --- a/client/plugins/fcc-create-nav-data/create-navigation-node.js +++ b/client/plugins/fcc-create-nav-data/create-navigation-node.js @@ -13,6 +13,7 @@ const guideDir = `../../../${ }/${locale}`; const pagesDir = path.resolve(__dirname, guideDir); +const indexMdRe = new RegExp(`\\${path.sep}index.md$`); function withGuidePrefix(str) { return `/guide${str}`; @@ -26,10 +27,9 @@ exports.createNavigationNode = function createNavigationNode(node) { parent } = node; - const nodeDir = fileAbsolutePath.replace(/\/index\.md$/, ''); - const dashedName = nodeDir.split('/').slice(-1)[0]; - const [, nodePath] = nodeDir.split(pagesDir); - + const nodeDir = path.resolve(fileAbsolutePath).replace(indexMdRe, ''); + const dashedName = nodeDir.split(path.sep).slice(-1)[0]; + const nodePath = nodeDir.split(pagesDir)[1].split(path.sep).join('/'); const parentPath = nodePath .split('/') .slice(0, -1) diff --git a/curriculum/getChallenges.js b/curriculum/getChallenges.js index ff4c51df97..f68826e0a0 100644 --- a/curriculum/getChallenges.js +++ b/curriculum/getChallenges.js @@ -47,6 +47,7 @@ async function buildCurriculum(file, curriculum) { challengeBlock = curriculum[superBlock].blocks[block]; } catch (e) { console.log(superBlock, block); + // eslint-disable-next-line no-process-exit process.exit(0); } const { meta } = challengeBlock; @@ -64,7 +65,7 @@ async function buildCurriculum(file, curriculum) { } function superBlockInfoFromPath(filePath) { - const [maybeSuper] = filePath.split('/'); + const [maybeSuper] = filePath.split(path.sep); return superBlockInfo(maybeSuper); } @@ -82,6 +83,6 @@ function superBlockInfo(fileName) { } function getBlockNameFromPath(filePath) { - const [, block] = filePath.split('/'); + const [, block] = filePath.split(path.sep); return block; }