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

lib/utils/build.js now requires postBuild function in gatsby-node #273

Merged
merged 4 commits into from May 8, 2016
Merged

lib/utils/build.js now requires postBuild function in gatsby-node #273

merged 4 commits into from May 8, 2016

Conversation

LukeSheard
Copy link
Contributor

Removes requirement for a post-build.js file in the root of the project for a custom post build step in gatsby build. Instead it requires for a postBuild export in the gatsby-node file in the root of the domain, where the webpack custom configuration is also stored.

Closes #239

Removes requirement for a post-build.js file in the root of the project for a custom post build step in gatsby build. Instead it requires for a postBuild export in the gatsby-node file in the root of the domain, where the webpack custom configuration is also stored.
@@ -10,7 +10,8 @@ function customPost (program, callback) {
const directory = program.directory
let customPostBuild
try {
customPostBuild = require(`${directory}/post-build`)
const gatsbyNodeConfig = require(`${directory}/gatsby-node`)
customPostBuild = gatsbyNodeConfig.postBuild
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
console.log('Failed to load custom post build script. It will be skipped.')
Copy link
Contributor

Choose a reason for hiding this comment

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

We actually want something here like

if (e.code !== 'MODULE_NOT_FOUND') {
so we can see the error. I'm not sure actually why the error wasn't being logged out here before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also the text of the log message should be something like console.log("Failed to load gatsby-node.js", e)

@KyleAMathews
Copy link
Contributor

Could you also remove the mention of post-build.js from the README?

Looking good otherwise!

Added a better error message for custom post-build actions defined in gatsby-node.js, explains to user that file cannot be used.

Updated README.md by removing post-build.js option in the project structure and including a new section explaining how to include a post-build function for users.
Correct some errors in the README.
@KyleAMathews
Copy link
Contributor

Looks great now (other than the 1 lint error).

Changed strings from double to single quotes to avoid eslint error.
@LukeSheard
Copy link
Contributor Author

Should be good now?

@KyleAMathews
Copy link
Contributor

Yup!

@KyleAMathews KyleAMathews merged commit bdbe104 into gatsbyjs:master May 8, 2016
@cusspvz
Copy link

cusspvz commented May 17, 2016

It would be nice to have Promise compatibility over this.

@KyleAMathews
Copy link
Contributor

@cusspvz perhaps down the road when all the APIs are set we could add promise support but for now, let's stick with callbacks for simplicity.

@cusspvz
Copy link

cusspvz commented May 17, 2016

@KyleAMathews Deal! Feel free to mention me whenever you need help with it.

@KyleAMathews
Copy link
Contributor

@cusspvz deal 👍 :-) my rough plan is once we switch to plugins to have a centralized API dispatch controller (or whatever this sort of thing should be called) which would then make it easy to check if the implementor returned a promise or will call the callback.

@cusspvz
Copy link

cusspvz commented May 17, 2016

2 years ago I've built this. I've used it several times on private projects, it is quite deprecated since most of the things it does can already be achieved easily with ES6 (such as classes).

But maybe you could rely on some of its code base and grab some ideas because based on what you're telling me, it doesn't seems too different of what it does. :)

@jlengstorf
Copy link
Contributor

Hiya @LukeSheard! 👋

This is definitely late, but on behalf of the entire Gatsby community, I wanted to say thank you for being here.

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (We’ve got t-shirts and hats, plus some socks that are really razzing our berries right now.)
  2. If you’re not already part of it, we just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. You’ll receive an email shortly asking you to confirm. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If you have questions, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again! 💪💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants