Comparing version 11.1.0 to 11.2.0
@@ -5,2 +5,3 @@ #!/usr/bin/env node | ||
const http = require('http'); | ||
const https = require('https'); | ||
const path = require('path'); | ||
@@ -63,2 +64,3 @@ const fs = require('fs'); | ||
{bold $} {cyan serve} --version | ||
{bold $} {cyan serve} folder_name | ||
{bold $} {cyan serve} [-l {underline listen_uri} [-l ...]] [{underline directory}] | ||
@@ -87,3 +89,3 @@ | ||
-n, --no-clipboard Do not copy the local address to the clipboard | ||
-u, --no-compression Do not compress files | ||
@@ -95,2 +97,6 @@ | ||
--ssl-cert Optional path to an SSL/TLS certificate to serve with HTTPS | ||
--ssl-key Optional path to the SSL/TLS certificate\'s private key | ||
{bold ENDPOINTS} | ||
@@ -182,4 +188,5 @@ | ||
const compress = args['--no-compression'] !== true; | ||
const httpMode = args['--ssl-cert'] && args['--ssl-key'] ? 'https' : 'http'; | ||
const server = http.createServer(async (request, response) => { | ||
const serverHandler = async (request, response) => { | ||
if (compress) { | ||
@@ -190,4 +197,11 @@ await compressionHandler(request, response); | ||
return handler(request, response, config); | ||
}); | ||
}; | ||
const server = httpMode === 'https' | ||
? https.createServer({ | ||
key: fs.readFileSync(args['--ssl-key']), | ||
cert: fs.readFileSync(args['--ssl-cert']) | ||
}, serverHandler) | ||
: http.createServer(serverHandler); | ||
server.on('error', (err) => { | ||
@@ -216,4 +230,4 @@ if (err.code === 'EADDRINUSE' && endpoint.length === 1 && !isNaN(endpoint[0])) { | ||
localAddress = `http://${address}:${details.port}`; | ||
networkAddress = `http://${ip}:${details.port}`; | ||
localAddress = `${httpMode}://${address}:${details.port}`; | ||
networkAddress = `${httpMode}://${ip}:${details.port}`; | ||
} | ||
@@ -362,2 +376,4 @@ | ||
'--symlinks': Boolean, | ||
'--ssl-cert': String, | ||
'--ssl-key': String, | ||
'-h': '--help', | ||
@@ -364,0 +380,0 @@ '-v': '--version', |
{ | ||
"name": "serve", | ||
"version": "11.1.0", | ||
"version": "11.2.0", | ||
"description": "Static file serving and directory listing", | ||
@@ -46,5 +46,5 @@ "scripts": { | ||
"compression": "1.7.3", | ||
"serve-handler": "6.1.0", | ||
"serve-handler": "6.1.2", | ||
"update-check": "1.5.2" | ||
} | ||
} |
@@ -9,5 +9,5 @@ ![](https://assets.zeit.co/image/upload/v1527770721/repositories/serve/serve-repo-banner.png) | ||
It behaves exactly like static deployments on [Now](https://zeit.co/now), so it's perfect for developing your static project. Then, when it's time to push it into production, you [deploy it](https://zeit.co/docs/examples/static). | ||
Once it's time to push your site to production, we recommend using [ZEIT Now](https://zeit.co/now). | ||
Furthermore, it provides a neat interface for listing the directory's contents: | ||
In general, `serve` also provides a neat interface for listing the directory's contents: | ||
@@ -26,3 +26,3 @@ ![screenshot](https://user-images.githubusercontent.com/6170607/40541195-167ff460-601b-11e8-8f66-3b0c7ff96cbb.png) | ||
Once that's done, you can run this command inside your project's directory: | ||
Once that's done, you can run this command inside your project's directory... | ||
@@ -33,2 +33,8 @@ ```bash | ||
...or specify which folder you want to serve: | ||
```bash | ||
serve folder_name | ||
``` | ||
Finally, run this command to see a list of all available options: | ||
@@ -35,0 +41,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
16889
345
85
+ Addedserve-handler@6.1.2(transitive)
- Removedserve-handler@6.1.0(transitive)
Updatedserve-handler@6.1.2