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

make sure to throw proper errors #20750

Merged
merged 2 commits into from
Jan 21, 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
19 changes: 10 additions & 9 deletions packages/gatsby-plugin-manifest/src/__tests__/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,16 @@ describe(`Test plugin manifest options`, () => {
icon: `non/existing/path`,
}

return onPostBootstrap(apiArgs, {
...manifestOptions,
...pluginSpecificOptions,
}).catch(err => {
expect(sharp).toHaveBeenCalledTimes(0)
expect(err).toBe(
`icon (non/existing/path) does not exist as defined in gatsby-config.js. Make sure the file exists relative to the root of the site.`
)
})
await expect(
onPostBootstrap(apiArgs, {
...manifestOptions,
...pluginSpecificOptions,
})
).rejects.toThrow(
`icon (non/existing/path) does not exist as defined in gatsby-config.js. Make sure the file exists relative to the root of the site.`
)

expect(sharp).toHaveBeenCalledTimes(0)
})

it(`doesn't write extra properties to manifest`, async () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/gatsby-plugin-manifest/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ const makeManifest = async (cache, reporter, pluginOptions, shouldLocalize) => {
if (icon !== undefined) {
// Check if the icon exists
if (!doesIconExist(icon)) {
throw `icon (${icon}) does not exist as defined in gatsby-config.js. Make sure the file exists relative to the root of the site.`
throw new Error(
`icon (${icon}) does not exist as defined in gatsby-config.js. Make sure the file exists relative to the root of the site.`
)
}

const sharpIcon = sharp(icon)
Expand Down
4 changes: 3 additions & 1 deletion scripts/gatsby-plugin-checker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ const updatePlugins = (updates, plugins) => {

const filterArchived = plugins => {
if (!process.env.GITHUB_API_TOKEN) {
throw `Please use instructions in README.md to setup GITHUB_API_TOKEN`
throw new Error(
`Please use instructions in README.md to setup GITHUB_API_TOKEN`
)
}

const promises = plugins.map(plugin => {
Expand Down