Skip to content

Commit

Permalink
Merge pull request #38 from jdvivar/feat/add-undefined-content-non-ht…
Browse files Browse the repository at this point in the history
…ml-files

feat: adding undefined content with non-html files edge case
  • Loading branch information
jdvivar committed Jul 10, 2023
2 parents 98f0aca + 46cea69 commit a70d7fa
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 a70d7fa

Please sign in to comment.