Skip to content

Commit cc5fa21

Browse files
committed
Serve current directory without the final dot (serve instead of serve .)
1 parent 6c85320 commit cc5fa21

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ http.createServer(function (req, res) {
3131
console.info("Server running on port 443.")
3232

3333
// serve static files, launch as: 'node index.js <static-path>'
34-
const staticPath = process.argv[2]
35-
if (staticPath) app.use(express.static(staticPath))
34+
if (require.main === module) { // called directly (not through require)
35+
const staticPath = process.argv[2]
36+
app.use(express.static(staticPath || process.cwd()))
37+
}
3638

3739
// export as module
3840
module.exports = app

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)