Skip to content

Commit 3fbed9b

Browse files
Barthélémy LedouxZachJW34
andauthored
fix: refactor function getFilesByGlob to use concat instead of isArray (#20245)
* fix: avoid using Array.isArray when possible * fix: add one more refactoring Co-authored-by: Zachary Williams <[email protected]> Co-authored-by: Zachary Williams <[email protected]>
1 parent eba409b commit 3fbed9b

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

packages/data-context/src/sources/FileDataSource.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ export class FileDataSource {
3131
}
3232

3333
async getFilesByGlob (cwd: string, glob: string | string[], globOptions?: GlobbyOptions) {
34-
const globs = Array.isArray(glob) ? glob : [glob]
34+
const globs = ([] as string[]).concat(glob)
3535

36-
const ignoreGlob = globOptions && Array.isArray(globOptions?.ignore) ? globOptions.ignore.concat('**/node_modules/**') : ['**/node_modules/**']
36+
const ignoreGlob = (globOptions?.ignore ?? []).concat('**/node_modules/**')
3737

3838
if (process.platform === 'win32') {
3939
// globby can't work with backwards slashes

packages/data-context/src/sources/migration/shouldShowSteps.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@ function getTestFilesGlobs (config: OldCypressConfig, type: 'component' | 'integ
1010

1111
const glob = config[k]?.testFiles ?? config.testFiles
1212

13-
if (glob && Array.isArray(glob)) {
14-
return glob
15-
}
16-
17-
if (glob && typeof glob === 'string') {
18-
return [glob]
13+
if (glob) {
14+
return ([] as string[]).concat(glob)
1915
}
2016

2117
return ['**/*']

0 commit comments

Comments
 (0)