refactor: rename cli to node and export render

This commit is contained in:
Pooya Parsa 2020-11-03 23:20:19 +01:00
parent 2dbaae6b7d
commit ae0fd1b108
2 changed files with 12 additions and 8 deletions

View File

@ -1,14 +1,16 @@
// @ts-ignore
import { render } from '~runtime/server'
// @ts-ignore
export { render } from '~runtime/server'
const debug = (label, ...args) => console.debug(`> ${label}:`, ...args)
async function main () {
async function cli () {
const url = process.argv[2] || '/'
debug('URL', url)
const debug = (label, ...args) => console.debug(`> ${label}:`, ...args)
const { html, status, headers } = await render(url)
debug('URL', url)
debug('Status', status)
for (const header in headers) {
debug(header, headers[header])
@ -17,7 +19,9 @@ async function main () {
console.log('\n', html)
}
main().catch((err) => {
console.error(err)
process.exit(1)
})
if (require.main === module) {
cli().catch((err) => {
console.error(err)
process.exit(1)
})
}