Skip to content

Commit

Permalink
fix(bugs): warn on no paths, handle initial errors on startup
Browse files Browse the repository at this point in the history
fixes #59
  • Loading branch information
estrattonbailey committed May 20, 2021
1 parent 5444b9f commit cf455be
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
11 changes: 11 additions & 0 deletions lib/renderStaticEntries.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ function renderStaticEntries (entries, config, options = {}) {
const file = require(entry)
const paths = await file.getStaticPaths()

if (!paths || !paths.length) {
formatLog({
color: 'yellow',
action: 'build',
meta: ' ',
description: `no paths to render`
})

continue
}

for (const url of paths) {
const time = timer()
const context = createContext({
Expand Down
8 changes: 6 additions & 2 deletions lib/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,12 @@ async function watch (config, options = {}) {
configWatcher.add(config.configFilepath)
}

staticIds.map(require)
dynamicIds.map(require)
try {
staticIds.map(require)
dynamicIds.map(require)
} catch (e) {
log(`\n ${c.red('error')}\n\n > ${e.stack || e}\n`)
}
}

module.exports = { buildFiles, watch }
6 changes: 5 additions & 1 deletion source-filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path')
const matched = require('matched')
const chokidar = require('chokidar')
const match = require('picomatch')
const assert = require('assert')

const { getCurrentConfig } = require('./lib/config')
const { buildFiles } = require('./lib/watch')
Expand Down Expand Up @@ -36,7 +37,10 @@ function createDefaultExtensions ({ baseDir }) {
}
}

function source (globs, { baseDir = cwd, file: root, extensions } = {}) {
function source (globs, { baseDir = cwd, file: root, extensions = {} } = {}) {
assert(path.isAbsolute(root), 'file should be an absolute path')
assert(path.isAbsolute(baseDir), 'baseDir should be an absolute path')

/*
* Current process variables
*/
Expand Down

0 comments on commit cf455be

Please sign in to comment.