Skip to content

fix: skip plugin if build command is empty #471

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

Merged
merged 3 commits into from
Jul 1, 2021
Merged

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Jul 1, 2021

If the build command is empty then we won't be able to generate anything, so skip running the plugin

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Jul 1, 2021
@ascorbic ascorbic requested a review from lindsaylevine July 1, 2021 10:59
@ascorbic ascorbic enabled auto-merge (squash) July 1, 2021 11:21
@@ -6,6 +6,11 @@ const doesNotNeedPlugin = ({ netlifyConfig, packageJson }) => {
const { build } = netlifyConfig
const { scripts = {} } = packageJson

if (!build.command) {
console.log("No build command specified in the site's Netlify config. Skipping plugin")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we maybe make this more noticeable somehow? i feel like it might get lost or like it might rly be worthy of a build failure. if we were going to fail the build tho, this check would have to come after/outside of doesNotNeedPlugin. therefore, we'd establish, ok, yes, so this site does need the plugin. it needs a build command for the plugin to work. then we could do the check, and then we should probably fail the build if it doesn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I didn't make it fail the build is because of the auto-install. It might be a site that somebody is building elsewhere, doing an export, then deploying. "doesNotNeedPlugin" wouldn't catch that scenario, because the command could be run elsewhere so wouldn;t show up in the config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just making it bright red or something

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if doesNotNeedPlugin doesn't catch that scenario, wouldnt that just fail blindly anyways?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would fail because of this check, so if we moved it then it wouldn't fail.

@ascorbic ascorbic force-pushed the fix/empty-build-command branch from c21847a to 84dc6f5 Compare July 1, 2021 13:22
if (!build.command) {
console.log(
redBright`⚠️ Warning: No build command specified in the site's Netlify config, so plugin will not run. This deploy will fail unless you have already exported the site. ⚠️`,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lindsaylevine How about this? It also shows up in the build status now.

@ascorbic ascorbic disabled auto-merge July 1, 2021 13:32
@ascorbic ascorbic enabled auto-merge (squash) July 1, 2021 13:36
@ascorbic ascorbic merged commit 4d0524b into main Jul 1, 2021
@ascorbic ascorbic deleted the fix/empty-build-command branch July 1, 2021 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants