project-dir-utils.ts 452 B

123456789101112131415
  1. import fs from 'node:fs';
  2. import path from 'node:path';
  3. import process from 'node:process';
  4. import { isServer } from '@growi/core/dist/utils/browser-utils';
  5. const isCurrentDirRoot = isServer() && fs.existsSync('./next.config.js');
  6. export const projectRoot = isCurrentDirRoot
  7. ? process.cwd()
  8. : path.resolve(__dirname, '../../');
  9. export function resolveFromRoot(relativePath: string): string {
  10. return path.resolve(projectRoot, relativePath);
  11. }