allow templating
This commit is contained in:
parent
e7022c8bd4
commit
98dac06085
|
@ -69,6 +69,9 @@ Options:
|
|||
|
||||
* `-p <port>` - i.e. `sudo serve-https -p 443` (defaults to 80+443 or 8443)
|
||||
* `-d <dirpath>` - i.e. `serve-https -d /tmp/` (defaults to `pwd`)
|
||||
* you can use `:hostname` as a template for multiple directories
|
||||
* Example A: `serve-https -d /srv/www/:hostname --sites localhost.foo.daplie.me,localhost.bar.daplie.me`
|
||||
* Example B: `serve-https -d ./:hostname/public/ --sites localhost.foo.daplie.me,localhost.bar.daplie.me`
|
||||
* `-c <content>` - i.e. `server-https -c 'Hello, World! '` (defaults to directory index)
|
||||
* `--express-app <path>` - path to a file the exports an express-style app (`function (req, res, next) { ... }`)
|
||||
* `--livereload` - inject livereload into all html pages (see also: [fswatch](http://stackoverflow.com/a/13807906/151312)), but be careful if `<dirpath>` has thousands of files it will spike your CPU usage to 100%
|
||||
|
|
|
@ -243,7 +243,7 @@ function run() {
|
|||
var argv = minimist(process.argv.slice(2));
|
||||
var port = parseInt(argv.p || argv.port || argv._[0], 10) || httpsPort;
|
||||
var livereload = argv.livereload;
|
||||
var defaultWebRoot = path.resolve(argv.d || argv._[1] || process.cwd());
|
||||
var defaultWebRoot = path.resolve(argv['default-web-root'] || argv.d || argv._[1] || process.cwd());
|
||||
var content = argv.c;
|
||||
var letsencryptHost = argv['letsencrypt-certs'];
|
||||
|
||||
|
@ -356,13 +356,15 @@ function run() {
|
|||
return {
|
||||
name: servername
|
||||
// there should always be a path
|
||||
, paths: nameparts.length && nameparts || [ defaultWebRoot ]
|
||||
, paths: nameparts.length && nameparts || [
|
||||
defaultWebRoot.replace(/(:hostname|:servername)/g, servername)
|
||||
]
|
||||
};
|
||||
});
|
||||
}
|
||||
// TODO use arrays in all things
|
||||
opts._old_server_name = opts.sites[0].name;
|
||||
opts.pubdir = defaultWebRoot;
|
||||
opts.pubdir = defaultWebRoot.replace(/(:hostname|:servername).*/, '');
|
||||
|
||||
if (argv.p || argv.port || argv._[0]) {
|
||||
opts.manualPort = true;
|
||||
|
|
Loading…
Reference in New Issue