xref: /expo/packages/create-expo/src/paths.ts (revision b7d15820)
1import os from 'os';
2import path from 'path';
3
4// The ~/.expo directory is used to store authentication sessions,
5// which are shared between EAS CLI and Expo CLI.
6export function dotExpoHomeDirectory(): string {
7  const home = os.homedir();
8  if (!home) {
9    throw new Error(
10      "Can't determine your home directory; make sure your $HOME environment variable is set."
11    );
12  }
13
14  let dirPath;
15  if (process.env.EXPO_STAGING) {
16    dirPath = path.join(home, '.expo-staging');
17  } else if (process.env.EXPO_LOCAL) {
18    dirPath = path.join(home, '.expo-local');
19  } else {
20    dirPath = path.join(home, '.expo');
21  }
22  return dirPath;
23}
24
25export const getStateJsonPath = (): string => path.join(dotExpoHomeDirectory(), 'state.json');
26