Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/generators/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { buildUrl } from '../util/url-builder.js';
import log from '../util/logger.js';
import { parseFile } from '../parsers/parser.js';

export async function generateCollections(collectionsConfig = {}, options) {
export async function generateCollections(collectionsConfig, options) {
collectionsConfig = collectionsConfig || {};
const source = join('.', options?.source || '');

return await Object.keys(collectionsConfig).reduce(async (memo, key) => {
Expand Down
3 changes: 2 additions & 1 deletion src/generators/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { stat } from 'fs/promises';
import { join } from 'path';
import { parseFile } from '../parsers/parser.js';

export async function generateData(dataConfig = {}, options) {
export async function generateData(dataConfig, options) {
dataConfig = dataConfig || {};
const source = join('.', options?.source || '');

return await Object.keys(dataConfig).reduce(async (memo, key) => {
Expand Down
23 changes: 23 additions & 0 deletions tests/generators/expected/null-fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"source": null,
"data_config": null,
"collections_config": null,
"_comments": null,
"_options": null,
"_structures": null,
"_select_data": null,
"generator": null,
"source_editor": null,
"paths": {
"uploads": null
},
"base_url": null,
"time": "2000-11-22T00:00:00.000Z",
"cloudcannon": {
"name": "cloudcannon-reader",
"version": "0.0.1"
},
"version": "0.0.3",
"data": {},
"collections": {}
}
15 changes: 15 additions & 0 deletions tests/generators/fixtures/null-fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"source": null,
"data_config": null,
"collections_config": null,
"_comments": null,
"_options": null,
"_structures": null,
"_select_data": null,
"generator": null,
"source_editor": null,
"paths": {
"uploads": null
},
"base_url": null
}
1 change: 1 addition & 0 deletions tests/generators/info.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ async function runTest(t, key) {
test('Generate JSON info', async (t) => runTest(t, 'standard'));
test('Generate JSON info with custom source', async (t) => runTest(t, 'custom-source'));
test('Generate JSON info with globs', async (t) => runTest(t, 'globs'));
test('Generate JSON info with null fields', async (t) => runTest(t, 'null-fields'));