From 97182444319d7fac23234ecd092961397eff9f63 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 2 Sep 2020 11:31:10 +0200 Subject: [PATCH] fix: watch curriculum changes --- client/plugins/fcc-source-challenges/gatsby-node.js | 4 +++- client/utils/buildChallenges.js | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/client/plugins/fcc-source-challenges/gatsby-node.js b/client/plugins/fcc-source-challenges/gatsby-node.js index 9425121ee3..9f1ec3a942 100644 --- a/client/plugins/fcc-source-challenges/gatsby-node.js +++ b/client/plugins/fcc-source-challenges/gatsby-node.js @@ -29,7 +29,8 @@ exports.sourceNodes = function sourceChallengesSourceNodes( const watcher = chokidar.watch(curriculumPath, { ignored: /(^|[\/\\])\../, persistent: true, - usePolling: true + usePolling: true, + cwd: curriculumPath }); watcher.on('change', filePath => @@ -45,6 +46,7 @@ File changed at ${filePath}, replacing challengeNode id ${challenge.id} }) .catch(e => reporter.error(`fcc-replace-challenge + attempting to replace ${filePath} ${e.message} diff --git a/client/utils/buildChallenges.js b/client/utils/buildChallenges.js index a23c9aea1c..92d2926132 100644 --- a/client/utils/buildChallenges.js +++ b/client/utils/buildChallenges.js @@ -2,16 +2,19 @@ const _ = require('lodash'); const { getChallengesForLang, - createChallenge, + createChallengeCreator, + challengesDir, getChallengesDirForLang } = require('../../curriculum/getChallenges'); const { locale } = require('../config/env.json'); exports.localeChallengesRootDir = getChallengesDirForLang(locale); -exports.replaceChallengeNode = locale => { - return async function replaceChallengeNode(fullFilePath) { - return await createChallenge(fullFilePath, null, locale); +const createChallenge = createChallengeCreator(challengesDir, locale); + +exports.replaceChallengeNode = () => { + return async function replaceChallengeNode(filePath) { + return await createChallenge(filePath); }; };