Skip to content

Commit 9fa5d1b

Browse files
developitrkostrzewski
authored andcommitted
Fixes the --dest option for preact serve --server config. Fixes #97. (#157)
1 parent 01f6329 commit 9fa5d1b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/commands/serve.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ async function serve(options) {
7575
await fs.writeFile(configFile, JSON.stringify(config));
7676

7777
await serveHttp2({
78+
options,
7879
config: configFile,
7980
configObj: config,
8081
server: options.server,
@@ -196,13 +197,13 @@ const SERVERS = {
196197
];
197198
},
198199
/** Writes the firebase/superstatic/simplehttp2server configuration to stdout or a file. */
199-
async config(options) {
200+
async config({ configObj, options }) {
200201
let dir = process.cwd(),
201202
outfile;
202203
if (options.dest && options.dest!=='-') {
203204
let isDir = false;
204205
try {
205-
isDir = (await fs.stat()).isDirectory();
206+
isDir = (await fs.stat(options.dest)).isDirectory();
206207
} catch (e) {}
207208
if (isDir) {
208209
dir = options.dest;
@@ -215,12 +216,13 @@ const SERVERS = {
215216
}
216217

217218
let config = JSON.stringify({
218-
...options.configObj,
219-
public: path.relative(dir, options.configObj.public)
219+
...configObj,
220+
public: path.relative(dir, configObj.public)
220221
}, null, 2);
221222

222223
if (outfile) {
223224
await fs.writeFile(path.resolve(dir, outfile), config);
225+
return `Configuration written to ${outfile}.`;
224226
}
225227
else {
226228
return config;

0 commit comments

Comments
 (0)