fix: build

This commit is contained in:
2023-03-14 18:04:29 +01:00
parent 3792a14e90
commit fd740b3091
185 changed files with 21932 additions and 71486 deletions

View File

@@ -12,13 +12,12 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {omitBy, isNil, reject, isEmpty, isArray, isObject} from 'lodash';
/**
* Filters only defined elements
*/
export function rejectNil<T>(array: Array<T | undefined | null>): T[] {
return reject(array, isNil) as T[];
// eslint-disable-next-line unicorn/no-null
return array.filter(it => it == null) as T[];
}
/**
@@ -33,5 +32,13 @@ export function mapNotNil<T, S>(array: readonly T[], transform: (element: T) =>
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export function cleanupEmpty<T extends object>(object: T): T {
return omitBy(object, it => isNil(it) || ((isObject(it) || isArray(it)) && isEmpty(it))) as T;
const out = {} as T;
for (const key in object) {
const value = object[key]
// eslint-disable-next-line unicorn/no-null
if (value != null && (typeof value !== 'object' || Object.values(value).length > 0)) {
out[key] = value
}
}
return out;
}

View File

@@ -13,7 +13,6 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {readdirSync, statSync} from 'fs';
import {flatMap} from 'lodash';
import path from 'path';
/**
@@ -24,9 +23,9 @@ export function expandPathToFilesSync(sourcePath: string, accept: (fileName: str
const directory = statSync(fullPath);
return directory.isDirectory()
? flatMap(readdirSync(fullPath), fragment =>
? readdirSync(fullPath).flatMap(fragment =>
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
)
)
: [fullPath].filter(accept);
}