async function ensureDirectory(dirPath) {
  if (!(await exists(dirPath))) {
    await fs.mkdir(dirPath, { recursive: true })
  }
}
Ensures a directory exists, creating it if necessary.
@param {string} dirPath - The directory path.