mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 01:53:55 +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
|
// @ts-ignore
|
||||||
import { render } from '~runtime/server'
|
import { render } from '~runtime/server'
|
||||||
|
// @ts-ignore
|
||||||
|
export { render } from '~runtime/server'
|
||||||
|
|
||||||
const debug = (label, ...args) => console.debug(`> ${label}:`, ...args)
|
async function cli () {
|
||||||
|
|
||||||
async function main () {
|
|
||||||
const url = process.argv[2] || '/'
|
const url = process.argv[2] || '/'
|
||||||
debug('URL', url)
|
|
||||||
|
const debug = (label, ...args) => console.debug(`> ${label}:`, ...args)
|
||||||
|
|
||||||
const { html, status, headers } = await render(url)
|
const { html, status, headers } = await render(url)
|
||||||
|
|
||||||
|
debug('URL', url)
|
||||||
debug('Status', status)
|
debug('Status', status)
|
||||||
for (const header in headers) {
|
for (const header in headers) {
|
||||||
debug(header, headers[header])
|
debug(header, headers[header])
|
||||||
@ -17,7 +19,9 @@ async function main () {
|
|||||||
console.log('\n', html)
|
console.log('\n', html)
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((err) => {
|
if (require.main === module) {
|
||||||
console.error(err)
|
cli().catch((err) => {
|
||||||
process.exit(1)
|
console.error(err)
|
||||||
})
|
process.exit(1)
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user