import fs from "fs" ; import path from "path" ; param rootDir param relativeFiles returns export function findFirstFileExists ( rootDir , ... relativeFiles ) { const normalizedRootDir = path . normalize ( rootDir ) ; for ( const f of relativeFiles ) { if ( f ) { const p = path . join ( normalizedRootDir , path . normalize ( f ) ) ; if ( fs . existsSync ( p ) ) { return p ; } } } return undefined ; } param p export function createDirectory ( p ) { fs . mkdirSync ( p , { recursive : true , mode : 0o755 } ) ; } param p returns export function statSync ( p ) { try { return fs . statSync ( p ) ; } catch ( _ ) { return undefined ; } } param p returns export function isDirectory ( p ) { return statSync ( p ) ?. isDirectory ( ) ?? false ; } param p returns export function isFile ( p ) { return statSync ( p ) ?. isFile ( ) ?? false ; }