diff --git a/packages/nitro/src/targets/cli/entry.ts b/packages/nitro/src/targets/node/entry.ts similarity index 53% rename from packages/nitro/src/targets/cli/entry.ts rename to packages/nitro/src/targets/node/entry.ts index 607ca89587..b8d6bcf7d5 100644 --- a/packages/nitro/src/targets/cli/entry.ts +++ b/packages/nitro/src/targets/node/entry.ts @@ -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) + }) +} diff --git a/packages/nitro/src/targets/cli/index.ts b/packages/nitro/src/targets/node/index.ts similarity index 100% rename from packages/nitro/src/targets/cli/index.ts rename to packages/nitro/src/targets/node/index.ts