1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Print list of pages when building (#6125)

* show pages created when building

* fix types
This commit is contained in:
Luc 2019-01-26 01:36:29 +08:00 committed by Tim Neutkens
parent 7ecf675834
commit 14604450cb

View file

@ -17,6 +17,17 @@ function collectPages (directory: string, pageExtensions: string[]): Promise<str
return glob(`**/*.+(${pageExtensions.join('|')})`, {cwd: directory})
}
function printTreeView(list: string[]) {
list
.sort((a, b) => a > b ? 1 : -1)
.forEach((item, i) => {
const corner = i === 0 ? list.length === 1 ? '─' : '┌' : i === list.length - 1 ? '└' : '├'
console.log(` \x1b[90m${corner}\x1b[39m ${item}`)
})
console.log()
}
export default async function build (dir: string, conf = null): Promise<void> {
if (!await isWriteable(dir)) {
throw new Error('> Build directory is not writeable. https://err.sh/zeit/next.js/build-dir-not-writeable')
@ -58,5 +69,8 @@ export default async function build (dir: string, conf = null): Promise<void> {
result.errors.forEach((error) => console.error(error))
throw new Error('> Build failed because of webpack errors')
}
printTreeView(Object.keys(pages))
await writeBuildId(distDir, buildId)
}