Skip to content

Commit 3a3b9f6

Browse files
authoredJan 18, 2024
workaround glob bug (#21)
fixes #20 workaround for isaacs/node-glob#570 Co-authored-by: Misha Kaletsky <mmkal@users.noreply.github.com>
1 parent 7b0fd6e commit 3a3b9f6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
 

‎src/presets/barrel.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ export const barrel: Preset<{
5050

5151
const ext = meta.filename.split('.').slice(-1)[0]
5252
const pattern = opts.include || `*.{${ext},${ext}x}`
53+
const exclude = Array.isArray(opts.exclude) ? opts.exclude : opts.exclude ? [opts.exclude] : undefined
5354

5455
const relativeFiles = glob
55-
.globSync(pattern, {cwd, ignore: opts.exclude})
56+
// todo[glob>10.3.10]: use exclude directly when https://github.com/isaacs/node-glob/issues/570 is fixed
57+
.globSync(pattern, {cwd, ignore: exclude?.map(e => e.replace(/^\.\//, ''))})
5658
.sort((a, b) => a.localeCompare(b))
5759
.filter(f => path.resolve(cwd, f) !== path.resolve(meta.filename))
5860
.map(f => `./${f}`.replace(/(\.\/)+\./g, '.'))

‎test/presets/barrel.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ test('generates typescript', () => {
7575
export * from './b'"
7676
`)
7777

78+
expect(
79+
preset.barrel({
80+
...params,
81+
options: {exclude: ['./a.ts', './b.ts']},
82+
}),
83+
).toMatchInlineSnapshot(`
84+
"export * from './a-util'
85+
export * from './b-util'
86+
export * from './c'
87+
export * from './index'
88+
export * from './util'"
89+
`)
90+
7891
expect(
7992
preset.barrel({
8093
...params,

0 commit comments

Comments
 (0)
Please sign in to comment.