From 58973be7befd62524fa473bd0a9e34dd538a2a40 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Thu, 25 Jul 2019 13:56:58 +0200 Subject: [PATCH] fix: make Gatsby wait for challenges to be sourced --- client/plugins/fcc-source-challenges/gatsby-node.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/plugins/fcc-source-challenges/gatsby-node.js b/client/plugins/fcc-source-challenges/gatsby-node.js index 50f4f64fc3..388b3f7164 100644 --- a/client/plugins/fcc-source-challenges/gatsby-node.js +++ b/client/plugins/fcc-source-challenges/gatsby-node.js @@ -32,7 +32,7 @@ exports.sourceNodes = function sourceChallengesSourceNodes( usePolling: true }); - watcher.on('ready', sourceAndCreateNodes).on('change', filePath => + watcher.on('change', filePath => /\.md$/.test(filePath) ? onSourceChange(filePath) .then(challenge => { @@ -73,4 +73,8 @@ File changed at ${filePath}, replacing challengeNode id ${challenge.id} `) ); } + + return new Promise((resolve, reject) => { + watcher.on('ready', () => sourceAndCreateNodes().then(resolve, reject)); + }); };