Skip to content

Commit

Permalink
fix(gatsby-plugin-manifest): create directories recursively (#27793)
Browse files Browse the repository at this point in the history
* fix(gatsby-plugin-manifest): create directories recursively

It's possible to have directories nested multiple layers deep or potentially that `public` isn't defined.

* fix typo

* fix tests
  • Loading branch information
KyleAMathews committed Nov 2, 2020
1 parent 8f8a419 commit 085d188
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/gatsby-plugin-manifest/src/__tests__/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ describe(`Test plugin manifest options`, () => {
// No sharp calls because this is manual mode: user provides all icon sizes
// rather than the plugin generating them
expect(sharp).toHaveBeenCalledTimes(0)
expect(fs.mkdirSync).toHaveBeenNthCalledWith(1, firstIconPath)
expect(fs.mkdirSync).toHaveBeenNthCalledWith(2, secondIconPath)
expect(fs.mkdirSync).toHaveBeenNthCalledWith(1, firstIconPath, {
recursive: true,
})
expect(fs.mkdirSync).toHaveBeenNthCalledWith(2, secondIconPath, {
recursive: true,
})
})

it(`invokes sharp if icon argument specified`, async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-manifest/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const makeManifest = async ({
const exists = fs.existsSync(iconPath)
//create destination directory if it doesn't exist
if (!exists) {
fs.mkdirSync(iconPath)
fs.mkdirSync(iconPath, { recursive: true })
}
paths[iconPath] = true
}
Expand Down

0 comments on commit 085d188

Please sign in to comment.