From 741434eb27f9c8b05b3f67d5c6f05209c6de3fdf Mon Sep 17 00:00:00 2001 From: Fabian Schultz Date: Thu, 19 Jul 2018 18:53:36 -0400 Subject: [PATCH] Add warning for relative paths in source-filesystem. (#6563) * Add warning for relative paths in source-filesystem. * Fix path instead of warning. --- src/gatsby-node.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gatsby-node.js b/src/gatsby-node.js index 2ee0c869a338a..fe68f08d80a67 100644 --- a/src/gatsby-node.js +++ b/src/gatsby-node.js @@ -1,5 +1,6 @@ const chokidar = require(`chokidar`) const fs = require(`fs`) +const path = require(`path`) const { Machine } = require(`xstate`) const { createFileNode } = require(`./create-file-node`) @@ -86,6 +87,12 @@ See docs here - https://www.gatsbyjs.org/packages/gatsby-source-filesystem/ `) } + // Validate that the path is absolute. + // Absolute paths are required to resolve images correctly. + if (!path.isAbsolute(pluginOptions.path)) { + pluginOptions.path = path.resolve(process.cwd(), pluginOptions.path) + } + const fsMachine = createFSMachine() let currentState = fsMachine.initialState let fileNodeQueue = new Map()