Skip to content

Commit a86a0ca

Browse files
committed
Error message for incorrect export type from db js file
1 parent 0ad8131 commit a86a0ca

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/cli/utils/load.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ module.exports = function (source, cb) {
1616

1717
var filename = path.resolve(source)
1818
delete require.cache[filename]
19-
data = require(filename)()
19+
var dataFn = require(filename)
20+
21+
if (typeof dataFn !== 'function') {
22+
throw new Error('The database is a JavaScript file but the export is not a function.')
23+
}
24+
25+
data = dataFn()
2026
cb(null, data)
2127

2228
} else if (is.JSON(source)) {

0 commit comments

Comments
 (0)