Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

serve

Package Overview
Dependencies
Maintainers
2
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serve - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

14

lib/index.js

@@ -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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc