Skip to content

Commit 6c76e04

Browse files
committed
fix(config): use host option if specified
1 parent 92d1223 commit 6c76e04

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/contentful.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,22 @@ const getContentName = (node, displayField) => {
6363
};
6464

6565
const getClient = async (options) => {
66-
const { accessToken } = options || {};
66+
const { accessToken, host } = options || {};
6767

6868
if (client) {
6969
return client;
7070
}
7171

72+
const params = {
73+
accessToken,
74+
};
75+
76+
if (host) {
77+
params.host = host;
78+
}
79+
7280
if (accessToken) {
73-
client = await contentful.createClient({
74-
accessToken,
75-
});
81+
client = await contentful.createClient(params);
7682
return client;
7783
}
7884

@@ -170,7 +176,7 @@ const getEnvironment = async (options) => {
170176
throw new Error(`Environment "${targetEnvironmentId}" is not available in space "${spaceId}"`);
171177
} else {
172178
throw new Error(
173-
'Missing environment id. Use -e <environment-id> or set environment variable CONTENTFUL_ENVIRONMENT_ID'
179+
'Missing environment id. Use -e <environment-id> or set environment variable CONTENTFUL_ENVIRONMENT_ID',
174180
);
175181
}
176182

@@ -263,7 +269,7 @@ const getLinkedEntries = (entries, allEntries, options) => {
263269
const entryIds = (entries || []).map((entry) => getContentId(entry));
264270
const linkedIds = (entries || []).reduce((result, entry) => [...result, ...getLinkedIds(entry, LINK_TYPE_ENTRY)], []);
265271
const newIds = linkedIds.filter(
266-
(id) => !collectedIds.includes(id) && !entryIds.includes(id) && includeIds.includes(id)
272+
(id) => !collectedIds.includes(id) && !entryIds.includes(id) && includeIds.includes(id),
267273
);
268274
const newEntries = allEntries.filter((entry) => newIds.includes(getContentId(entry)));
269275

0 commit comments

Comments
 (0)