mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
feat: update tests
feat: update tests feat: update tests
This commit is contained in:
19
packages/es-mapping-generator/test/common.ts
Normal file
19
packages/es-mapping-generator/test/common.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import path from 'path';
|
||||
import {readdirSync, statSync} from 'fs';
|
||||
|
||||
/**
|
||||
* Expand a path to a list of all files deeply contained in it
|
||||
*/
|
||||
export function expandPathToFilesSync(sourcePath: string, accept: (fileName: string) => boolean): string[] {
|
||||
const fullPath = path.resolve(sourcePath);
|
||||
const directory = statSync(fullPath);
|
||||
|
||||
return directory.isDirectory()
|
||||
? // eslint-disable-next-line unicorn/prefer-spread
|
||||
([] as string[]).concat(
|
||||
...readdirSync(fullPath).map(fragment =>
|
||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||
),
|
||||
)
|
||||
: [fullPath].filter(accept);
|
||||
}
|
||||
Reference in New Issue
Block a user