Skip to content

Commit

Permalink
feat: adding undefined content with non-html files edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
jdvivar-eb committed Jul 10, 2023
1 parent acc834e commit 46cea69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion add-web-component-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const addChild = (body, child, position) => {
}

module.exports = function (options, content, outputPath) {
if (typeof outputPath !== 'string' || !outputPath) { return content }
if (typeof outputPath !== 'string' || !outputPath || !content) { return content }

if (!!options.path && !!options.specifiers) {
throw new Error('You may configure a path function or import specifiers, but not both')
Expand Down
10 changes: 10 additions & 0 deletions test/add-web-component-definitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ test('Not html', t => {
)
})

test('Undefined with non-html files', t => {
t.is(
addWebComponentDefinitions.bind(null, {})(
undefined,
'main.css'
),
undefined
)
})

test('Is html', t => {
t.is(
addWebComponentDefinitions.bind(null, {})(
Expand Down

0 comments on commit 46cea69

Please sign in to comment.