Skip to content

Commit 04d1681

Browse files
committed
chore(fastboot test config): allow object export with a deprecation warning
1 parent 159d537 commit 04d1681

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

lib/helpers.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { URL } = require('url');
77
const JSONfn = require('json-fn');
88
const FastBoot = require('fastboot');
99
const bodyParser = require('body-parser');
10+
const { deprecate } = require('util');
1011

1112
function createMockRequest(app) {
1213
app.post(
@@ -104,13 +105,15 @@ function makeFastbootTestingConfig(config, pkg) {
104105

105106
if (fs.existsSync(fastbootTestConfigPath)) {
106107
const fastbootTestConfig = require(fastbootTestConfigPath);
107-
if (typeof fastbootTestConfig !== 'function') {
108-
throw new Error(
109-
`Expected export of ${fastbootTestConfigPath} to be a function. Instead found (${typeof fastbootTestConfig}).`
110-
);
111-
}
112108

113-
customized = fastbootTestConfig();
109+
if (typeof fastbootTestConfig === 'function') {
110+
customized = fastbootTestConfig();
111+
} else {
112+
deprecate(
113+
() => Object.assign(customized, fastbootTestConfig),
114+
`Exporting an object from ${fastbootTestConfigPath} has been deprecated. Please export a function which returns an object instead.`,
115+
)();
116+
}
114117
}
115118

116119
return Object.assign({}, config, defaults, customized);

0 commit comments

Comments
 (0)