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

Before Hook Promise #754

Open
richardmatthewsdev opened this issue Jan 16, 2017 · 3 comments
Open

Before Hook Promise #754

richardmatthewsdev opened this issue Jan 16, 2017 · 3 comments

Comments

@richardmatthewsdev
Copy link

richardmatthewsdev commented Jan 16, 2017

Hey,

I am having an issue with the before hook on app.coffee where the Roots compilation doesn't appear to wait for the promise to be resolved before compiling.

In an empty Roots project, I would expect that this code would cause Roots to never compile.

axis         = require 'axis'
rupture      = require 'rupture'
autoprefixer = require 'autoprefixer-stylus'
js_pipeline  = require 'js-pipeline'
css_pipeline = require 'css-pipeline'

promise = ->
  return new Promise((resolve, reject) ->

  )

module.exports =
  ignores: ['readme.md', '**/layout.*', '**/_*', '.gitignore', 'ship.*conf']

  extensions: [
    js_pipeline(files: 'assets/js/*.coffee'),
    css_pipeline(files: 'assets/css/*.styl')
  ]

  stylus:
    use: [axis(), rupture(), autoprefixer()]
    sourcemap: true

  'coffee-script':
    sourcemap: true

  before: promise

  jade:
    pretty: true

This is a problem for me because I am trying to fetch content from an API in multiple requests and I am needing Roots to wait until all of the requests have been made before it compiles the site.

Any help would be much appreciated!

Thanks,

@jescalan
Copy link
Owner

Hey @reinkaos! Thanks for pointing this out. It appears as if this is a bug. I'll have it patched up and a new release out to resolve it shortly 👬

@jescalan
Copy link
Owner

Hey actually, anyone interested in trying to submit them patch themselves? This is a fairly straightforward change if you understand how promises work 😁

This is the method that needs to be slightly retooled: https://github.com/jescalan/roots/blob/master/lib/api/compile.coffee#L106

Basically, W.resolve should be used here instead of lift

@richardmatthewsdev
Copy link
Author

Hey @jescalan thanks for getting back to me, I look forward to this issue being fixed :).

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

No branches or pull requests

2 participants