js-dxtools / webpack-validator

Validates your webpack config with Joi
MIT License
295 stars 29 forks source link

fix(devServer.cert): accepting proper types in cert,key and ca fields #133

Closed karol-maciaszek closed 7 years ago

karol-maciaszek commented 7 years ago

Bugfix for proper validation of devServer: cert, key, ca fields.

Once you want a custom certificate to be used by webpack-dev-server you need to pass following options in devServer section of config file:

{
  cert: fs.readFileSync('path/to/cert/file'),
  key: fs.readFileSync('path/to/key/file'),
  ca: [fs.readFileSync('path/to/ca1/file'), fs.readFileSync('path/to/ca2/file')] // optional
}

Current implementation of webpack-validator allows Joi.string() in these fields, while these are Buffer's.

The PR changes devServer schema to accept Buffer's as long as String's https://github.com/hapijs/joi/blob/v9.0.4/API.md#binary.

Here is how dev-server does it internally: https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L315.

kentcdodds commented 7 years ago

Code looks fine, I'm not sure why suddenly the code coverage of no-root-files-node-modules-nameclash.js is less than 100%. I just re-ran the master build and I'm seeing the same results. I'm guessing we have a transitive dependency that fixed a bug that reported we had 100% code coverage when we really didn't or something.

All that said, you're stuff is good, so I'll go ahead and merge it. Hopefully I can have some time today to look into the issue and try to fix it.

kentcdodds commented 7 years ago

This has been released in v2.2.8. Thanks!

karol-maciaszek commented 7 years ago

That was fast, thanks!