Skip to content

The open alternative to Salesforce, designed for AI.

600 B
Raw Blame
import { stat } from 'node:fs/promises';
import { isAbsolute } from 'node:path';

import { type ToolingResult } from '@/app/types/tooling-result.type';

export const validateAppPath = async (
  appPath: string,
): Promise<ToolingResult<null>> => {
  if (
    isAbsolute(appPath) &&
    (await stat(appPath).catch(() => null))?.isDirectory()
  ) {
    return { success: true, data: null, diagnostics: [] };
  }

  return {
    success: false,
    error: {
      code: 'INVALID_APP_PATH',
      message: 'appPath must be an absolute path to an existing directory.',
    },
    diagnostics: [],
  };
};