project-dir-utils.ts 488 B

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