mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
By default print some messages to the console.
Also added a silent option if someone don't want those messages.
This commit is contained in:
parent
d7048e13fa
commit
430789b99f
|
@ -10,12 +10,12 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
|||
const argv = parseArgs(process.argv.slice(2), {
|
||||
alias: {
|
||||
h: 'help',
|
||||
v: 'verbose',
|
||||
s: 'silent',
|
||||
o: 'outdir'
|
||||
},
|
||||
boolean: ['h'],
|
||||
default: {
|
||||
v: false,
|
||||
s: false,
|
||||
o: null
|
||||
}
|
||||
})
|
||||
|
@ -34,8 +34,8 @@ if (argv.help) {
|
|||
|
||||
Options
|
||||
-h - list this help
|
||||
-v - run export with the verbose mode
|
||||
-o - set the output dir (defaults to '.out')
|
||||
-s - do not print any messages to console
|
||||
`)
|
||||
process.exit(0)
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ if (!existsSync(join(dir, 'pages'))) {
|
|||
}
|
||||
|
||||
const options = {
|
||||
verbose: argv.verbose,
|
||||
silent: argv.silent,
|
||||
outdir: argv.outdir ? resolve(argv.outdir) : resolve(dir, '.out')
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ export default async function (dir, options) {
|
|||
const outDir = options.outdir
|
||||
const nextDir = join(dir, '.next')
|
||||
|
||||
log(` Exporting to: ${outDir}\n`)
|
||||
|
||||
if (!existsSync(nextDir)) {
|
||||
console.error('Build your with "next build" before running "next start".')
|
||||
process.exit(1)
|
||||
|
@ -64,9 +66,7 @@ export default async function (dir, options) {
|
|||
}
|
||||
|
||||
for (const path of exportPaths) {
|
||||
if (options.verbose) {
|
||||
console.log(` exporing path: ${path}`)
|
||||
}
|
||||
log(` exporing path: ${path}`)
|
||||
|
||||
const { page, query } = exportPathMap[path]
|
||||
const req = { url: path }
|
||||
|
@ -81,6 +81,14 @@ export default async function (dir, options) {
|
|||
const html = await renderToHTML(req, res, page, query, renderOpts)
|
||||
writeFileSync(htmlFilepath, html, 'utf8')
|
||||
}
|
||||
|
||||
// Add an empty line to the console for the better readability.
|
||||
log('')
|
||||
|
||||
function log (message) {
|
||||
if (options.silent) return
|
||||
console.log(message)
|
||||
}
|
||||
}
|
||||
|
||||
function copyPages (nextDir, outDir, buildId) {
|
||||
|
|
Loading…
Reference in a new issue