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
11 changes: 9 additions & 2 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export default () => {
domain = 'localhost',
outputDir = buildDir,
} = program.optsObj

var port = 0, domain_final = domain
if(domain.split(':')[1]){
port = domain.split(':')[1].split('/')[0]
domain_final = domain.split(':')[0]
}
console.log("domain_final = ",domain_final,"port = ",port)

const pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json')))
const basename = ((p) => p.endsWith('/') ? p : p + '/')(pkg.homepage ? url.parse(pkg.homepage).pathname : '')
Expand All @@ -39,9 +46,9 @@ export default () => {
const writer = new Writer(buildDirPath, outputDirPath)
writer.move('index.html', '200.html')

const server = new Server(buildDirPath, basename, 0, pkg.proxy)
const server = new Server(buildDirPath, basename, port, pkg.proxy)
server.start().then(() => {
const crawler = new Crawler(`http://${domain}:${server.port()}${basename}`, options.snapshotDelay, options)
const crawler = new Crawler(`http://${domain_final}:${server.port()}${basename}`, options.snapshotDelay, options)
return crawler.crawl(({ urlPath, html }) => {
if (!urlPath.startsWith(basename)) {
console.log(`❗ Refusing to crawl ${urlPath} because it is outside of the ${basename} sub-folder`)
Expand Down