Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-recipes): Fix gatsby config all function #23811

Merged
merged 1 commit into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,113 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`gatsby-plugin resource all returns plugins as array 1`] = `
Array [
Object {
"id": "gatsby-source-filesystem",
"name": "gatsby-source-filesystem",
"options": Object {
"name": "pages",
"path": "\${__dirname}/src/pages",
},
"shadowableFiles": Array [],
"shadowedFiles": Array [],
},
Object {
"id": "gatsby-transformer-sharp",
"name": "gatsby-transformer-sharp",
"options": undefined,
"shadowableFiles": Array [],
"shadowedFiles": Array [],
},
Object {
"id": "gatsby-plugin-emotion",
"name": "gatsby-plugin-emotion",
"options": undefined,
"shadowableFiles": Array [],
"shadowedFiles": Array [],
},
Object {
"id": "gatsby-plugin-typography",
"name": "gatsby-plugin-typography",
"options": Object {
"pathToConfigModule": "src/utils/typography",
},
"shadowableFiles": Array [],
"shadowedFiles": Array [],
},
Object {
"id": "gatsby-transformer-remark",
"name": "gatsby-transformer-remark",
"options": Object {
"plugins": Array [
Object {
"options": Object {
"maxWidth": 590,
},
"resolve": "gatsby-remark-images",
},
Object {
"options": Object {
"wrapperStyle": "margin-bottom: 1.0725rem",
},
"resolve": "gatsby-remark-responsive-iframe",
},
"gatsby-remark-prismjs",
"gatsby-remark-copy-linked-files",
"gatsby-remark-smartypants",
],
},
"shadowableFiles": Array [],
"shadowedFiles": Array [],
},
Object {
"id": "gatsby-plugin-sharp",
"name": "gatsby-plugin-sharp",
"options": undefined,
"shadowableFiles": Array [],
"shadowedFiles": Array [],
},
Object {
"id": "gatsby-plugin-google-analytics",
"name": "gatsby-plugin-google-analytics",
"options": Object {
"trackingId": "UA-774017-3",
},
"shadowableFiles": Array [],
"shadowedFiles": Array [],
},
Object {
"id": "gatsby-plugin-manifest",
"name": "gatsby-plugin-manifest",
"options": Object {
"background_color": null,
"display": "minimal-ui",
"icon": "static/logo.png",
"name": "Bricolage",
"short_name": "Bricolage",
"start_url": "/",
"theme_color": null,
},
"shadowableFiles": Array [],
"shadowedFiles": Array [],
},
Object {
"id": "gatsby-plugin-offline",
"name": "gatsby-plugin-offline",
"options": undefined,
"shadowableFiles": Array [],
"shadowedFiles": Array [],
},
Object {
"id": "gatsby-plugin-react-helmet",
"name": "gatsby-plugin-react-helmet",
"options": undefined,
"shadowableFiles": Array [],
"shadowedFiles": Array [],
},
]
`;

exports[`gatsby-plugin resource creates default gatsby-config.js if there isn't one already 1`] = `
Object {
"_message": "Installed gatsby-plugin-foo in gatsby-config.js",
Expand Down
8 changes: 4 additions & 4 deletions packages/gatsby-recipes/src/providers/gatsby/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ module.exports.all = async ({ root }) => {
const plugins = getPluginsFromConfig(configSrc)

// TODO: Consider mapping to read function
return plugins.map(name => {
return plugins.map(plugin => {
const { shadowedFiles, shadowableFiles } = listShadowableFilesForTheme(
root,
name
plugin.name
)

return {
id: name,
name,
id: plugin.name,
...plugin,
shadowedFiles,
shadowableFiles,
}
Expand Down
6 changes: 6 additions & 0 deletions packages/gatsby-recipes/src/providers/gatsby/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ describe(`gatsby-plugin resource`, () => {
})
})

test(`all returns plugins as array`, async () => {
const result = await plugin.all({ root: STARTER_BLOG_FIXTURE })

expect(result).toMatchSnapshot()
})

test(`does not add the same plugin twice by default`, async () => {
const configSrc = await fs.readFile(configPath, `utf8`)
let newConfigSrc = addPluginToConfig(configSrc, {
Expand Down