# core/predicates/exclusion.predicate.ts

> 27 lines of code and 4 definitions.

Tree: Bane's Lab Build Scripts
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-predicates-exclusion-predicate-ts
Source text: https://banes-lab.com/source/build-scripts/core/predicates/exclusion.predicate.ts.txt

Listed in [core/predicates](https://banes-lab.com/api/source/build-scripts/core/predicates.md), after [core/predicates/asset.predicate.ts](https://banes-lab.com/source/build-scripts/core/predicates/asset.predicate.ts.md) and before [core/predicates/graph.predicate.ts](https://banes-lab.com/source/build-scripts/core/predicates/graph.predicate.ts.md).

## Definitions

- `isPublished` (lexical_declaration, line 28, exported)
- `thirdPartyFolders` (lexical_declaration, line 12)
- `exclusionOf` (lexical_declaration, line 14, exported)
- `extension` (lexical_declaration, line 15, exported)

## Contained in

- [core/predicates](https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-predicates.md)

## Used by

- [core/converters/anatomy.converter.ts](https://banes-lab.com/source/build-scripts/core/converters/anatomy.converter.ts.md)
- [core/loaders/tree.loader.ts](https://banes-lab.com/source/build-scripts/core/loaders/tree.loader.ts.md)

## Linked from

- [core/converters](https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-converters.md)
- [core/loaders](https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-loaders.md)

## Source

```typescript
import {
    BACKUP_MARK,
    BINARY_EXTENSIONS,
    MEDIA_EXTENSIONS,
    THIRD_PARTY_KEYS,
} from "#configuration/constants/exclusion.constants";
import { basename, extname } from "node:path";
import type { ExclusionReason } from "@ssot/secrets";
import type { PublishedFacts } from "#types/structure.types";
import { absolutePath } from "@ssot/paths";

const thirdPartyFolders = THIRD_PARTY_KEYS.map((key) => absolutePath(key));

export const exclusionOf = function exclusionOf(file: string): ExclusionReason | null {
    const extension = extname(file).toLowerCase();
    if (thirdPartyFolders.some((folder) => file.startsWith(folder))) {
        return "third-party-rule-text";
    }
    if (basename(file).includes(BACKUP_MARK)) {
        return "backup";
    }
    if (MEDIA_EXTENSIONS.has(extension)) {
        return "rendered-media";
    }
    return BINARY_EXTENSIONS.has(extension) ? "binary" : null;
};

export const isPublished = function isPublished(file: PublishedFacts, generatedSources: boolean): boolean {
    return file.excluded === undefined && !file.inherited && (generatedSources || !file.generated);
};
```
