Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ async function serve(options) {
await fs.writeFile(configFile, JSON.stringify(config));

await serveHttp2({
options,
config: configFile,
configObj: config,
server: options.server,
Expand Down Expand Up @@ -196,13 +197,13 @@ const SERVERS = {
];
},
/** Writes the firebase/superstatic/simplehttp2server configuration to stdout or a file. */
async config(options) {
async config({ configObj, options }) {
let dir = process.cwd(),
outfile;
if (options.dest && options.dest!=='-') {
let isDir = false;
try {
isDir = (await fs.stat()).isDirectory();
isDir = (await fs.stat(options.dest)).isDirectory();
} catch (e) {}
if (isDir) {
dir = options.dest;
Expand All @@ -215,12 +216,13 @@ const SERVERS = {
}

let config = JSON.stringify({
...options.configObj,
public: path.relative(dir, options.configObj.public)
...configObj,
public: path.relative(dir, configObj.public)
}, null, 2);

if (outfile) {
await fs.writeFile(path.resolve(dir, outfile), config);
return `Configuration written to ${outfile}.`;
}
else {
return config;
Expand Down