Skip to content

Commit

Permalink
update error message with more context
Browse files Browse the repository at this point in the history
  • Loading branch information
koddsson committed Oct 18, 2023
1 parent 321a9a3 commit 880d7fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/dynamic-import-vars/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function dynamicImportVariables({ include, exclude, warnOnError, errorWhenNoFile

if (errorWhenNoFilesFound && paths.length === 0) {
this.error(
new Error('No files found when trying to dynamically load concatted string')
new Error(
`No files found in ${glob} when trying to dynamically load concatted string from ${id}`
)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,13 @@ test('throws if no files in dir when option is set', async (t) => {
input: 'fixture-no-files.js',
plugins: [dynamicImportVars({ errorWhenNoFilesFound: true })]
});
} catch (_) {
} catch (error) {
t.deepEqual(
error.message,
`No files found in ./module-dir-c/*.js when trying to dynamically load concatted string from ${require.resolve(
'./fixtures/fixture-no-files.js'
)}`
);
thrown = true;
}
t.true(thrown);
Expand Down

0 comments on commit 880d7fb

Please sign in to comment.