We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The https configuration requires a synchronous export from a module. But in some cases it would be useful to export a promise:
fs
With fs callback functions (kind of ugly):
const fs = require('fs') module.exports = Promise.all([ new Promise((resolve, reject) => { fs.readFile(__dirname + '/server.cert', (error, cert) => error ? reject(error) : resolve(cert)) }), new Promise((resolve, reject) => { fs.readFile(__dirname + '/server.key', (error, key) => error ? reject(error) : resolve(key)) }) ]).then(([cert, key]) => ({ cert, key, passphrase: '12345' }))
With fs experimental promises or fs-extra:
fs-extra
const fs = require('fs').promises // const fs = require('fs-extra') module.exports = Promise.all([ fs.readFile(__dirname + '/server.cert'), fs.readFile(__dirname + '/server.key') ]).then(([cert, key]) => ({ cert, key, passphrase: '12345' }))
devcert
const devcert = require('devcert') module.exports = (async () => ({ ...(await devcert.certificateFor('localhost')), passphrase: '12345' })()
Can be one-lined when passphrase is not needed:
module.exports = require('devcert').certificateFor('localhost')
Personally, I would prefer being able to pass an object to the https option, so asynchronous stuff can be handled by the user, outside live-server:
https
const liveServer = require('live-server') const devcert = require('devcert') ;(async () => liveServer.start({ // ... https: await devcert.certificateFor('localhost') })()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The https configuration requires a synchronous export from a module. But in some cases it would be useful to export a promise:
Using
fs
asynchronous functionsWith
fs
callback functions (kind of ugly):With
fs
experimental promises orfs-extra
:Using
devcert
:Can be one-lined when passphrase is not needed:
Personally, I would prefer being able to pass an object to the
https
option, so asynchronous stuff can be handled by the user, outside live-server:The text was updated successfully, but these errors were encountered: