lwsjs / local-web-server

A lean, modular web server for rapid full-stack development.
MIT License
1.22k stars 86 forks source link

--directory option errors with --stack option #119

Closed dotnetCarpenter closed 5 years ago

dotnetCarpenter commented 5 years ago

local-web-server: 2.6.1 lws: 1.3.2

Steps to reproduce:

  1. Create a folder called docs (mkdir docs)
  2. Create a file called middleware.js
  3. Copy/paste the following into middleware.js
    module.exports = MiddlewareBase => class Example extends MiddlewareBase {
    middleware (options) {
        return (ctx, next) => {
            ctx.response.body = 'Hello'
        }
    }
    }
  4. In the terminal write: ./node_modules/.bin/ws -d docs/ --stack middleware.js

Error output:

./node_modules/.bin/ws --stack middleware.js --directory docs/
UNKNOWN_OPTION: Unknown option: --directory
    at commandLineArgs (node_modules/command-line-args/dist/index.js:1347:21)
    at WsServe.getOptions (node_modules/lws/lib/command/serve.js:269:18)
    at WsServe.execute (node_modules/lws/lib/command/serve.js:280:20)
    at WsServe.execute (node_modules/local-web-server/lib/command/serve.js:11:18)
    at Map.start (node_modules/cli-commands/index.js:26:18)
    at WsCliApp.start (node_modules/lws/lib/cli-app.js:9:26)
    at Function.run (node_modules/lws/lib/cli-app.js:15:29)
    at Object.<anonymous> (node_modules/local-web-server/bin/cli.js:5:29)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
./node_modules/.bin/ws -d docs/ --stack middleware.js
UNKNOWN_OPTION: Unknown option: -d
    at commandLineArgs (node_modules/command-line-args/dist/index.js:1347:21)
    at WsServe.getOptions (node_modules/lws/lib/command/serve.js:269:18)
    at WsServe.execute (node_modules/lws/lib/command/serve.js:280:20)
    at WsServe.execute (node_modules/local-web-server/lib/command/serve.js:11:18)
    at Map.start (node_modules/cli-commands/index.js:26:18)
    at WsCliApp.start (node_modules/lws/lib/cli-app.js:9:26)
    at Function.run (node_modules/lws/lib/cli-app.js:15:29)
    at Object.<anonymous> (node_modules/local-web-server/bin/cli.js:5:29)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
75lb commented 5 years ago

hi.. --directory is an option from the lws-static middleware but you don't have that middleware included in your stack.

If you run this command you'll see that --directory is not listed in the options: (npx runs the local installation)

npx ws --stack middleware.js --help

That's because the lws-stack middleware was not loaded.. try this command:

npx ws --stack middleware.js lws-static --help

You should now see --directory listed so you can now run something like:

npx ws --stack middleware.js lws-static --directory docs/