/**
 * The directory of the app code
 * @author Gabe Abrams
 */

// Import libs
import fs from 'fs';
import path from 'path';

// Import constants
import TOP_LEVEL_DIRECTORY from './TOP_LEVEL_DIRECTORY';

// Get project directory
let APP_DIRECTORY = TOP_LEVEL_DIRECTORY;

// If there's an "app" subfolder, use that as the app directory
const appDir = path.join(APP_DIRECTORY, '/app');
if (fs.existsSync(appDir) && fs.lstatSync(appDir).isDirectory()) {
  APP_DIRECTORY = appDir;
}

export default APP_DIRECTORY;
