How to use the minimist.port function in minimist

To help you get started, we’ve selected a few minimist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 1wheel / hot-server / index.js View on Github external
#!/usr/bin/env node
var express = require('express')
var serveStatic = require('serve-static')
var serveIndex = require('serve-index')
var SocketServer = require('ws').Server
var fs = require('fs')
var chokidar = require('chokidar')
var child = require('child_process')
var PORT = require('minimist')(process.argv.slice(2)).port || 3989

// set up express static server with a websocket
var server = express()
  .get('*', injectHTML)
  .use('/', serveIndex('./'))
  .on('listening', () => {
    child.exec('open http://localhost:' + PORT)
    console.log('hot-server http://localhost:' + PORT)
process.on('uncaughtException', (err => 
  err.errno == 'EADDRINUSE' ? server.listen(++PORT) : 0)) //inc PORT if in use

// append websocket/injecter script to all html pages served
github machawk1 / wail / tools / ui-dev-server.js View on Github external
import express from 'express'
import webpack from 'webpack'
import webpackDev from 'webpack-dev-middleware'
import webpackHot from 'webpack-hot-middleware'
import uiDevConfig from '../webpackConfigs/ui/webpack.config'

const port = require('minimist')(process.argv.slice(2)).port

if(port === null) {
  console.error('A port was not specified as an argument. Please rerun with --port [port]')

const app = express()
const compile = webpack(uiDevConfig)

const dev = webpackDev(compile,{
  publicPath: uiDevConfig.output.publicPath,
  stats: {
    colors: true