Skip to content

Commit

Permalink
Fix using Express middleware with a config file which exports a function
Browse files Browse the repository at this point in the history
Fixes #238
  • Loading branch information
insin committed Jan 19, 2017
1 parent 608c0a9 commit 0cc3cc8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**Fixed:**

- Fix using Express middleware with a config file which exports a function [[#238](https://github.com/insin/nwb/issues/238)]

# 0.14.1 / 2017-01-13

**Fixed:**
Expand Down
4 changes: 3 additions & 1 deletion src/expressMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export default function nwbMiddleware(express, options = {}) {
'The express module must be passed as the first argument to nwb middleware'
)

let userConfig = getUserConfig({config: options.config}, {required: true})
// We need to do an intial grab of the user config to determine the project
// type.
let userConfig = getUserConfig({_: ['serve'], config: options.config}, {required: true})
if (!SERVE_APP_CONFIG[userConfig.type]) {
throw new Error(
`nwb Express middleware is unable to serve anything for a ${userConfig.type} project.`
Expand Down
6 changes: 4 additions & 2 deletions tests/fixtures/projects/express-middleware/nwb.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module.exports = {
type: 'react-app'
module.exports = function() {
return {
type: 'react-app'
}
}

0 comments on commit 0cc3cc8

Please sign in to comment.