UNPKG

project-setup-validation-yaml

Version:

Validate environment variables, files and directories. Supports YAML configuration

49 lines (48 loc) 1.36 kB
export interface FilePath { path: string; options?: { ensurePath?: boolean; baseDir?: string; }; } export interface DirFileObject { baseDir?: string; dirs?: (string | FilePath)[]; files?: (string | FilePath)[]; } /** * * Validates whether files and directories exists, creates them if ensurePath is set to true * * Directories will be evaluated first, then files * * Example: * * ``` * validateProjectDirectories({ baseDir: __dirname, // this is optional, defaults to process.cwd() files: [ "index.ts", "src/validators/index.ts", // if exists - do nothing { path: "src/components/test.ts", // if exists do nothing, otherwise create empty file options: { ensurePath: true } }, "src/doesntexist/a.ts" // Doesn't exist, will log error and terminate ], dirs: [ "/src/validators", // if exists - do nothing { path: "src/test/test", // if exists do nothing, otherwise create empty directories recursively options: { ensurePath: true } }, "/src/doesntexist/" // Doesn't exist, will log error and terminate ] }) ``` */ export declare function validateProjectDirectories(obj: DirFileObject, reporter?: Function): void;