Skip to content

Commit

Permalink
fix: allow jsonFormat with format:html
Browse files Browse the repository at this point in the history
  • Loading branch information
is2ei committed May 21, 2022
1 parent b83d922 commit f282dae
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 12 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ interface ListRender {
interface ListOptions {
names?: string[];
extendedFolderInfo?: boolean;
jsonFormat?: 'names' | 'extended';
}

interface ListOptionsJsonFormat extends ListOptions {
format: 'json';
jsonFormat?: 'names' | 'extended';
// Required when the URL parameter `format=html` exists
render?: ListRender;
}
Expand Down
3 changes: 0 additions & 3 deletions lib/dirList.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ const dirList = {
if (options.list.format === 'html' && typeof options.list.render !== 'function') {
return new TypeError('The `list.render` option must be a function and is required with html format')
}
if (options.list.format === 'html' && options.list.jsonFormat != null) {
return new TypeError('The `list.jsonFormat` option must be with json format')
}
}

}
Expand Down
8 changes: 0 additions & 8 deletions test/dir-list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ t.test('throws when `list.format` is html and `list render` is not a function',
t.equal(err.message, 'The `list.render` option must be a function and is required with html format')
})

t.test('throws when `list.format` is html and `list.jsonFormat` is given', t => {
t.plan(2)

const err = dirList.validateOptions({ list: { format: 'html', render: () => '', jsonFormat: 'extended' } })
t.type(err, TypeError)
t.equal(err.message, 'The `list.jsonFormat` option must be with json format')
})

t.test('dir list wrong options', t => {
t.plan(3)

Expand Down

0 comments on commit f282dae

Please sign in to comment.