Skip to content

Commit b874496

Browse files
committed
Improve regex and tests
1 parent 55c6e45 commit b874496

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

packages/app/src/cli/models/app/app.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
AppSchema,
23
CurrentAppConfiguration,
34
LegacyAppConfiguration,
45
getAppScopes,
@@ -92,6 +93,33 @@ describe('app schema validation', () => {
9293

9394
expect(isCurrentAppSchema(config)).toBe(false)
9495
})
96+
97+
test('extension_directories should be transformed to double asterisks', () => {
98+
const config = {
99+
...CORRECT_CURRENT_APP_SCHEMA,
100+
extension_directories: ['extensions/*'],
101+
}
102+
const parsed = AppSchema.parse(config)
103+
expect(parsed.extension_directories).toEqual(['extensions/**'])
104+
})
105+
106+
test('extension_directories is not transformed if it ends with double asterisks', () => {
107+
const config = {
108+
...CORRECT_CURRENT_APP_SCHEMA,
109+
extension_directories: ['extensions/**'],
110+
}
111+
const parsed = AppSchema.parse(config)
112+
expect(parsed.extension_directories).toEqual(['extensions/**'])
113+
})
114+
115+
test('extension_directories is not transformed if it doesnt end with a wildcard', () => {
116+
const config = {
117+
...CORRECT_CURRENT_APP_SCHEMA,
118+
extension_directories: ['extensions'],
119+
}
120+
const parsed = AppSchema.parse(config)
121+
expect(parsed.extension_directories).toEqual(['extensions'])
122+
})
95123
})
96124
})
97125

packages/app/src/cli/models/app/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ function removeTrailingPathSeparator(value: string[] | undefined) {
5959
// If a path ends with a single asterisk, modify it to end with a double asterisk.
6060
// This is to support the glob pattern used by chokidar and watch for changes in subfolders.
6161
function fixSingleWildcards(value: string[] | undefined) {
62-
return value?.map((dir) => dir.replace(/\*$/, '**'))
62+
// eslint-disable-next-line no-useless-escape
63+
return value?.map((dir) => dir.replace(/([^\*])\*$/, '$1**'))
6364
}
6465

6566
/**

0 commit comments

Comments
 (0)