Skip to content

Commit bb4ff54

Browse files
committedMar 31, 2022
add --shared-array-buffers and --header options
1 parent 68b3a12 commit bb4ff54

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed
 

‎bin/servez

+24-19
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,28 @@ function genQRCode(s) {
3737

3838
const optionSpec = {
3939
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', },
4544
{ 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', },
6062
],
6163
prepend: `Usage: servez [options] [path-to-serve]`,
6264
helpStyle: {
@@ -91,6 +93,9 @@ if (args.version) {
9193
process.exit(0);
9294
}
9395

96+
args.headers = args.header;
97+
delete args.header;
98+
9499
const fs = require('fs');
95100
const path = require('path');
96101
const {QrCode, Ecc} = require('../lib/qrcodegen');

0 commit comments

Comments
 (0)
Please sign in to comment.