Comparing version 3.1.0 to 3.2.0
@@ -8,4 +8,3 @@ // Native | ||
const compress = require('micro-compress') | ||
const getPort = require('get-port') | ||
const portUsed = require('tcp-port-used') | ||
const detect = require('detect-port') | ||
const {grey} = require('chalk') | ||
@@ -51,9 +50,8 @@ | ||
const server = flags.unzipped ? micro(handler) : micro(compress(handler)) | ||
let port = flags.port | ||
portUsed.check(flags.port, '127.0.0.1').then(async inUse => { | ||
let port = flags.port | ||
if (inUse) { | ||
port = await getPort() | ||
console.log(grey(`Port ${flags.port} already in use, falling back to ${port}`)) | ||
detect(port).then(open => { | ||
if (open !== port) { | ||
port = open | ||
console.log(grey(`Port ${port} already in use, falling back to ${open}`)) | ||
} | ||
@@ -60,0 +58,0 @@ |
@@ -5,3 +5,3 @@ // Packages | ||
const pathType = require('path-type') | ||
const {red} = require('chalk') | ||
const chalk = require('chalk') | ||
@@ -28,3 +28,3 @@ const copyToClipboard = async text => { | ||
if (!await pathType.dir(current)) { | ||
console.error(red('Specified directory doesn\'t exist!')) | ||
console.error(chalk.red('Specified directory doesn\'t exist!')) | ||
process.exit(1) | ||
@@ -34,11 +34,19 @@ } | ||
if (!process.env.NOW) { | ||
let message = `Running on ${url}` | ||
let message = chalk.green('Serving!') | ||
message += '\n\n' | ||
const localURL = `http://localhost:${details.port}` | ||
message += `• ${chalk.bold('Locally: ')} ${localURL}\n` | ||
message += `• ${chalk.bold('On the Network: ')} ${url}\n\n` | ||
const copied = await copyToClipboard(url) | ||
if (copied) { | ||
message = `${message} [copied to clipboard]` | ||
message += `${chalk.grey('Copied local address to clipboard!')}\n\n` | ||
} | ||
console.log(message) | ||
process.stdout.write('\x1Bc') | ||
process.stdout.write(message) | ||
} | ||
} |
@@ -103,2 +103,5 @@ // Native | ||
// Serve files without a mime type as text | ||
stream.mime.default_type = 'text/plain' | ||
return stream(req, related, { | ||
@@ -105,0 +108,0 @@ dotfiles: 'allow' |
{ | ||
"name": "serve", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Static file serving and directory listing", | ||
@@ -32,3 +32,4 @@ "scripts": { | ||
"unicorn/no-process-exit": 0, | ||
"max-params": 0 | ||
"max-params": 0, | ||
"camelcase": 0 | ||
} | ||
@@ -58,5 +59,5 @@ }, | ||
"copy-paste": "^1.3.0", | ||
"detect-port": "^1.1.0", | ||
"filesize": "^3.5.4", | ||
"fs-promise": "^1.0.0", | ||
"get-port": "^2.1.0", | ||
"handlebars": "^4.0.6", | ||
@@ -70,5 +71,4 @@ "ip": "^1.1.4", | ||
"send": "^0.14.2", | ||
"tcp-port-used": "^0.1.2", | ||
"update-notifier": "^1.0.3" | ||
} | ||
} |
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
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
16554
17
406
+ Addeddetect-port@^1.1.0
+ Addedaddress@1.2.2(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddetect-port@1.6.1(transitive)
+ Addedms@2.1.3(transitive)
- Removedget-port@^2.1.0
- Removedtcp-port-used@^0.1.2
- Removeddebug@0.7.4(transitive)
- Removeddeep-is@0.1.2(transitive)
- Removedget-port@2.1.0(transitive)
- Removedis2@0.0.9(transitive)
- Removedq@0.9.7(transitive)
- Removedtcp-port-used@0.1.2(transitive)