Skip to content

Commit 8c1eec9

Browse files
javilobo8leo
authored andcommitted
Added --treeless flag for disabling directory listings (vercel#261)
1 parent b5637aa commit 8c1eec9

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/options.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ exports.options = [
4545
name: 'open',
4646
description: 'Open local address in browser',
4747
defaultValue: false
48+
},
49+
{
50+
name: 'treeless',
51+
description: `Don't display statics tree`,
52+
defaultValue: false
4853
}
4954
]
5055

@@ -56,7 +61,17 @@ exports.minimist = {
5661
s: 'single',
5762
u: 'unzipped',
5863
n: 'clipless',
59-
o: 'open'
64+
o: 'open',
65+
t: 'treeless'
6066
},
61-
boolean: ['auth', 'cors', 'silent', 'single', 'unzipped', 'clipless', 'open']
67+
boolean: [
68+
'auth',
69+
'cors',
70+
'silent',
71+
'single',
72+
'unzipped',
73+
'clipless',
74+
'open',
75+
'treeless'
76+
]
6277
}

lib/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ module.exports = coroutine(function*(req, res, flags, current, ignoredFiles) {
139139
)
140140

141141
// If it works, send the directory listing to the user
142-
if (renderedDir) {
142+
// If is treeless, stepover
143+
if (renderedDir && !flags.treeless) {
143144
return micro.send(res, 200, renderedDir)
144145
}
145146

0 commit comments

Comments
 (0)