From d4bcb77cb8dab0165f5ee1df041f0aa179cea14e Mon Sep 17 00:00:00 2001 From: "Avery N. Nortonsmith" Date: Wed, 29 Jul 2020 14:48:54 -0400 Subject: [PATCH] Add option --no-server for --watch --- src/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 0fa33ea..9688eed 100644 --- a/src/index.js +++ b/src/index.js @@ -14,6 +14,7 @@ const getEnv = (argKey, envKey) => { ); }; const isWatching = process.argv.includes('--watch'); +const isServing = !process.argv.includes('--no-server'); const ROOT = getEnv('--root=', 'SERGEY_ROOT') || './'; const PORT = Number(getEnv('--port=', 'SERGEY_PORT')) || 8080; @@ -483,8 +484,6 @@ const sergeyRuntime = async () => { if (isWatching) { const chokidar = require('chokidar'); - const connect = require('connect'); - const serveStatic = require('serve-static'); const watchRoot = ROOT.endsWith('/') ? ROOT.substring(0, ROOT.length - 1) @@ -500,6 +499,13 @@ const sergeyRuntime = async () => { watcher.on('change', task); watcher.on('add', task); watcher.on('unlink', task); + + if (!isServing) { + return; + } + + const connect = require('connect'); + const serveStatic = require('serve-static'); connect() .use(serveStatic(OUTPUT))