From 0624e4d56ecdc467caf7219f54a672f2dcf08985 Mon Sep 17 00:00:00 2001 From: Dustin Schau Date: Fri, 4 Jan 2019 10:44:27 -0600 Subject: [PATCH] fix(gatsby): test plugin name to handle symlinks, rather than path This simple PR augments the behavior to test the plugin's name, rather than the plugin's resolved path, in the case that it could be symlinked/linked. This seems to match the behavior we're expecting, and _again_ will be cleaned up when #10787 lands. --- .../query-runner/__tests__/query-compiler.js | 9 ++++++++- .../src/internal-plugins/query-runner/query-compiler.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/src/internal-plugins/query-runner/__tests__/query-compiler.js b/packages/gatsby/src/internal-plugins/query-runner/__tests__/query-compiler.js index 6da385f8dde73..8c141076dd37a 100644 --- a/packages/gatsby/src/internal-plugins/query-runner/__tests__/query-compiler.js +++ b/packages/gatsby/src/internal-plugins/query-runner/__tests__/query-compiler.js @@ -68,7 +68,12 @@ describe(`resolveThemes`, () => { it(`returns empty array if zero themes detected`, () => { ;[ [], - [{ resolve: path.join(base, `gatsby-plugin-whatever`) }], + [ + { + name: `gatsby-plugin-whatever`, + resolve: path.join(base, `gatsby-plugin-whatever`), + }, + ], undefined, ].forEach(testRun => { expect(resolveThemes(testRun)).toEqual([]) @@ -80,6 +85,7 @@ describe(`resolveThemes`, () => { expect( resolveThemes([ { + name: theme, resolve: path.join(base, `gatsby-theme-example`), }, ]) @@ -92,6 +98,7 @@ describe(`resolveThemes`, () => { expect( resolveThemes([ { + name: theme, resolve: path.join(base, theme), }, ]) diff --git a/packages/gatsby/src/internal-plugins/query-runner/query-compiler.js b/packages/gatsby/src/internal-plugins/query-runner/query-compiler.js index 002a888a50419..345f550be5289 100644 --- a/packages/gatsby/src/internal-plugins/query-runner/query-compiler.js +++ b/packages/gatsby/src/internal-plugins/query-runner/query-compiler.js @@ -66,7 +66,7 @@ const overlayErrorID = `graphql-compiler` const resolveThemes = (plugins = []) => plugins.reduce((merged, plugin) => { - if (plugin.resolve.includes(`gatsby-theme-`)) { + if (plugin.name.includes(`gatsby-theme-`)) { merged.push(plugin.resolve) } return merged