ConditionalScripts
constConditionalScripts:FilePolicyDefinition<ConditionalScriptsConfig|undefined> &object
Defined in: policies/ConditionalScripts.ts:222
A policy that validates conditional script requirements in package.json.
Type Declaration
Section titled “Type Declaration”requiresConfig
Section titled “requiresConfig”requiresConfig:
true
Remarks
Section titled “Remarks”Use this policy when you want to enforce that the presence of one script requires other scripts to also exist. For example, if “build” exists, then “clean” must also exist.
Example
Section titled “Example”import { makePolicy } from "repopo";import { ConditionalScripts } from "repopo/policies";
makePolicy(ConditionalScripts, { config: { rules: [ // If "build" exists, "clean" must also exist (with auto-fix default) { ifPresent: "build", requires: [{ clean: "rimraf dist" }] }, // If "test" exists, "test:coverage" must also exist (no auto-fix) { ifPresent: "test", requires: ["test:coverage"] }, ],} })