Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ export default () => {
.option('--build-dir <directory>', `Specify where the JS app lives. Defaults to 'build'`)
.option('--domain <domain>', `The local domain to use for scraping. Defaults to 'localhost'`)
.option('--output-dir <directory>', `Where to write the snapshots. Defaults to in-place (i.e. same as build-dir)`)
.option('--output-style <style>', `How should routes be outputted? Defaults to "{name}.html".`)
.parse(process.argv)

const {
buildDir = 'build',
domain = 'localhost',
outputDir = buildDir,
outputStyle = '{name}.html'
} = program.optsObj

const pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json')))
Expand Down Expand Up @@ -52,7 +54,7 @@ export default () => {
if (urlPath.endsWith('/')) {
filename = `${urlPath}index.html`
} else if (path.extname(urlPath) == '') {
filename = `${urlPath}.html`
filename = outputStyle.replace(/{name}/g, urlPath)
}
console.log(`✏️ Saving ${urlPath} as ${filename}`)
writer.write(filename, html)
Expand Down