Comparing version 10.0.2 to 10.1.0
@@ -21,2 +21,3 @@ #!/usr/bin/env node | ||
const boxen = require('boxen'); | ||
const compression = require('compression'); | ||
@@ -28,2 +29,3 @@ // Utilities | ||
const lookup = promisify(dns.lookup); | ||
const compressionHandler = promisify(compression()); | ||
@@ -157,8 +159,21 @@ const warning = (message) => chalk`{yellow WARNING:} ${message}`; | ||
const startEndpoint = (endpoint, config, args) => { | ||
const server = http.createServer((request, response) => handler(request, response, config)); | ||
const startEndpoint = (endpoint, config, args, previous) => { | ||
const {isTTY} = process.stdout; | ||
const clipboard = args['--no-clipboard'] !== true; | ||
const compress = args['--no-compression'] !== true; | ||
const server = http.createServer(async (request, response) => { | ||
if (compress) { | ||
await compressionHandler(request, response); | ||
} | ||
return handler(request, response, config); | ||
}); | ||
server.on('error', (err) => { | ||
if (err.code === 'EADDRINUSE' && endpoint.length === 1 && !isNaN(endpoint[0])) { | ||
startEndpoint([0], config, args, endpoint[0]); | ||
return; | ||
} | ||
console.error(error(`Failed to serve: ${err.stack}`)); | ||
@@ -203,2 +218,6 @@ process.exit(1); | ||
if (previous) { | ||
message += chalk.red(`\n\nThis port was picked because ${chalk.underline(previous)} is in use.`); | ||
} | ||
if (clipboard) { | ||
@@ -281,2 +300,6 @@ try { | ||
if (file === 'now.json' || file === 'package.json') { | ||
console.error(warning('The config files `now.json` and `package.json` are deprecated. Please use `serve.json`.')); | ||
} | ||
break; | ||
@@ -318,2 +341,3 @@ } | ||
'--no-clipboard': Boolean, | ||
'--no-compression': Boolean, | ||
'-h': '--help', | ||
@@ -326,2 +350,3 @@ '-v': '--version', | ||
'-n': '--no-clipboard', | ||
'-u': '--no-compression', | ||
// This is deprecated and only for backwards-compatibility. | ||
@@ -335,3 +360,5 @@ '-p': '--listen' | ||
await updateCheck(args['--debug']); | ||
if (process.env.NO_UPDATE_CHECK !== '1') { | ||
await updateCheck(args['--debug']); | ||
} | ||
@@ -338,0 +365,0 @@ if (args['--version']) { |
{ | ||
"name": "serve", | ||
"version": "10.0.2", | ||
"version": "10.1.0", | ||
"description": "Static file serving and directory listing", | ||
@@ -45,5 +45,6 @@ "scripts": { | ||
"clipboardy": "1.2.3", | ||
"serve-handler": "5.0.3", | ||
"compression": "1.7.3", | ||
"serve-handler": "5.0.6", | ||
"update-check": "1.5.2" | ||
} | ||
} |
@@ -39,3 +39,3 @@ ![](https://assets.zeit.co/image/upload/v1527770721/repositories/serve/serve-repo-banner.png) | ||
To customize `serve`'s behavior, create a `serve.json` file and insert any of [these properties](https://github.com/zeit/serve-handler#options). In addition, `serve` will also detect `now.json` files if they contain the `static` property. | ||
To customize `serve`'s behavior, create a `serve.json` file and insert any of [these properties](https://github.com/zeit/serve-handler#options). | ||
@@ -42,0 +42,0 @@ ## API |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
15570
316
9
5
+ Addedcompression@1.7.3
+ Addedaccepts@1.3.8(transitive)
+ Addedcompressible@2.0.18(transitive)
+ Addedcompression@1.7.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedmime-db@1.52.01.53.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedms@2.0.0(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addedon-headers@1.0.2(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedserve-handler@5.0.6(transitive)
+ Addedvary@1.1.2(transitive)
- Removedglob-slash@1.0.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedserve-handler@5.0.3(transitive)
Updatedserve-handler@5.0.6