@@ -37,26 +37,28 @@ function genQRCode(s) {
37
37
38
38
const optionSpec = {
39
39
options : [
40
- { option : 'help' , alias : 'h' , type : 'Boolean' , description : 'displays help' } ,
41
- { option : 'port' , alias : 'p' , type : 'Int' , description : 'port' , default : '8080' } ,
42
- { option : 'version' , type : 'Boolean' , description : 'print version' } ,
43
- { option : 'scan' , type : 'Boolean' , description : 'scan for open port' , default : 'true' , } ,
44
- { option : 'dirs' , type : 'Boolean' , description : 'show directory listing' , default : 'true' , } ,
40
+ { option : 'help' , alias : 'h' , type : 'Boolean' , description : 'displays help' } ,
41
+ { option : 'port' , alias : 'p' , type : 'Int' , description : 'port' , default : '8080' } ,
42
+ { option : 'version' , type : 'Boolean' , description : 'print version' } ,
43
+ { option : 'scan' , type : 'Boolean' , description : 'scan for open port' , default : 'true' , } ,
45
44
{ option : 'qr' , type : 'Boolean' , description : 'print QR Code for root url' } ,
46
- { option : 'cors' , type : 'Boolean' , description : 'send CORS headers' , default : 'true' , } ,
47
- { option : 'local' , type : 'Boolean' , description : 'local machine only' , default : 'false' , } ,
48
- { option : 'index' , type : 'Boolean' , description : 'serve index.html for directories' , default : 'true' , } ,
49
- { option : 'extensions' , type : '[String]' , description : 'extensions to try if path does not exist' , default : '["html"]' , } ,
50
- { option : 'unity-hack' , type : 'Boolean' , description : 'ignore .gz and .br when computing content type' , default : 'true' , } ,
51
- { option : 'gzip' , type : 'Boolean' , description : 'serve .gz files if they exist' , default : 'false' , } ,
52
- { option : 'brotli' , type : 'Boolean' , description : 'serve .br files if they exist' , default : 'false' , } ,
53
- { option : 'robots' , type : 'Boolean' , description : 'serve a robots.txt if one does not exist' , default : 'true' , } ,
54
- { option : 'hidden' , type : 'Boolean' , description : 'show hidden dotfiles' , default : 'false' , } ,
55
- { option : 'username' , type : 'String' , description : 'username for basic auth' } ,
56
- { option : 'password' , type : 'String' , description : 'password for basic auth' } ,
57
- { option : 'ssl' , alias : 'S' , type : 'Boolean' , description : 'enable https (will use fake cert if not specified)' , } ,
58
- { option : 'cert' , alias : 'C' , type : 'String' , description : 'Path to ssl cert file' , } ,
59
- { option : 'key' , alias : 'K' , type : 'String' , description : 'Path to ssl key file' , } ,
45
+ { option : 'dirs' , type : 'Boolean' , description : 'show directory listing' , default : 'true' , } ,
46
+ { option : 'cors' , type : 'Boolean' , description : 'send CORS headers' , default : 'true' , } ,
47
+ { option : 'local' , type : 'Boolean' , description : 'local machine only' , default : 'false' , } ,
48
+ { option : 'index' , type : 'Boolean' , description : 'serve index.html for directories' , default : 'true' , } ,
49
+ { option : 'extensions' , type : '[String]' , description : 'extensions to try if path does not exist' , default : '["html"]' , } ,
50
+ { option : 'unity-hack' , type : 'Boolean' , description : 'ignore .gz and .br when computing content type' , default : 'true' , } ,
51
+ { option : 'shared-array-buffers' , type : 'Boolean' , description : "include headers 'Cross-Origin-Opener-Policy': 'same-origin' and 'Cross-Origin-Embedder-Policy': 'require-corp'" , default : 'false' , } ,
52
+ { option : 'header' , type : 'Object' , description : 'extra headers to include eg --header=Content-Language:de-DE' , mergeRepeatedObjects : true } ,
53
+ { option : 'gzip' , type : 'Boolean' , description : 'serve .gz files if they exist' , default : 'false' , } ,
54
+ { option : 'brotli' , type : 'Boolean' , description : 'serve .br files if they exist' , default : 'false' , } ,
55
+ { option : 'robots' , type : 'Boolean' , description : 'serve a robots.txt if one does not exist' , default : 'true' , } ,
56
+ { option : 'hidden' , type : 'Boolean' , description : 'show hidden dotfiles' , default : 'false' , } ,
57
+ { option : 'username' , type : 'String' , description : 'username for basic auth' } ,
58
+ { option : 'password' , type : 'String' , description : 'password for basic auth' } ,
59
+ { option : 'ssl' , alias : 'S' , type : 'Boolean' , description : 'enable https (will use fake cert if not specified)' , } ,
60
+ { option : 'cert' , alias : 'C' , type : 'String' , description : 'Path to ssl cert file' , } ,
61
+ { option : 'key' , alias : 'K' , type : 'String' , description : 'Path to ssl key file' , } ,
60
62
] ,
61
63
prepend : `Usage: servez [options] [path-to-serve]` ,
62
64
helpStyle : {
@@ -91,6 +93,9 @@ if (args.version) {
91
93
process . exit ( 0 ) ;
92
94
}
93
95
96
+ args . headers = args . header ;
97
+ delete args . header ;
98
+
94
99
const fs = require ( 'fs' ) ;
95
100
const path = require ( 'path' ) ;
96
101
const { QrCode, Ecc} = require ( '../lib/qrcodegen' ) ;
0 commit comments