Let key, cert as a file path

This commit is contained in:
Jhen 2016-05-03 05:29:43 +08:00
parent aa2d877064
commit 227fe0bab3

View File

@ -1,3 +1,15 @@
#! /usr/bin/env node
var fs = require('fs');
var path = require('path');
var argv = require('minimist')(process.argv.slice(2));
function readFile(filePath) {
return fs.readFileSync(path.resolve(process.cwd(), filePath), 'utf-8');
}
if (argv.protocol === 'https') {
argv.key = argv.key ? readFile(argv.key) : null;
argv.cert = argv.cert ? readFile(argv.cert) : null;
}
require('./server')(argv);