mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 00:23:53 +00:00
refactor: rename cli to node and export render
This commit is contained in:
parent
2dbaae6b7d
commit
ae0fd1b108
@ -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)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user