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-source-wordpress): image fixes #29813

Merged
merged 5 commits into from
Mar 1, 2021
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
Expand Up @@ -54,7 +54,7 @@ export const buildGatsbyNodeObjectResolver = ({ field, fieldName }) => async (
schema: { typePrefix: prefix },
} = getPluginOptions()

if (!existingNode.__typename.startsWith(prefix)) {
if (existingNode?.__typename && !existingNode.__typename.startsWith(prefix)) {
existingNode.__typename = buildTypeName(existingNode.__typename)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const { isWebUri } = require(`valid-url`)
const Queue = require(`better-queue`)
const readChunk = require(`read-chunk`)
const fileType = require(`file-type`)
const { createProgress } = require(`gatsby-source-filesystem/utils`)

const { createFileNode } = require(`gatsby-source-filesystem/create-file-node`)
const {
Expand Down Expand Up @@ -431,7 +430,7 @@ module.exports = ({
}

if (totalJobs === 0) {
bar = createProgress(`Downloading remote files`, reporter)
bar = reporter.createProgress(`Downloading remote files`)
bar.start()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export const errorPanicker = ({
)
)
reporter.panic(error)
} else {
console.error(error)
reporter.panic()
Comment on lines +142 to +143
Copy link
Contributor

Choose a reason for hiding this comment

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

What's wrong with panicking with an error?

Suggested change
console.error(error)
reporter.panic()
reporter.panic(error)

Copy link
Contributor Author

@TylerBarnes TylerBarnes Mar 1, 2021

Choose a reason for hiding this comment

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

reporter.panic() is broken right now - this will result in Gatsby logging "There was an error" and quitting with no additional info https://gatsby.canny.io/ideas/p/reporterpanic-is-broken

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,11 @@ const replaceNodeHtmlLinks = ({ wpUrl, nodeString, node }) => {
const normalizedPath = path.replace(/\\/g, ``)

// replace normalized match with relative path
const thisMatchRegex = new RegExp(normalizedMatch, `g`)
const thisMatchRegex = new RegExp(
normalizedMatch + `(?!/?wp-content|/?wp-admin|/?wp-includes)`,
`g`
)

nodeString = nodeString.replace(thisMatchRegex, normalizedPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's always helpful to add a comment with an example of what this converts into

} catch (e) {
console.error(e)
Expand Down