Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 28x 28x 27x 1x 4x 30x 28x 28x 28x 1x 27x | import path from 'path'; import { homedir } from 'os'; /** * Path to the home directory. * @type {string} */ const home = homedir(); /** * Retrieves the user ID (UID) of the current process. * @returns {number | null} The UID of the current process if available, otherwise null. */ function getUid() { if (process.platform !== 'win32' && process.getuid) { return process.getuid(); } return null; } /** * Checks if the current environment is a fake root environment. * @returns {boolean} True if the environment is a fake root, false otherwise. */ function isFakeRoot() { return Boolean(process.env.FAKEROOTKEY); } /** * Checks if a given user ID belongs to the root user. * @param {number | null} uid - The user ID to check. * @returns {boolean} True if the user ID belongs to the root user, false otherwise. */ function isRootUser(uid) { return uid === 0; } /** * Checks if the current operating system is Windows. * @returns {boolean} True if the operating system is Windows, false otherwise. */ function isWindows() { return process.platform === 'win32'; } /** * Indicates whether the current environment is running as the root user. * @type {boolean} */ const ROOT_USER = isRootUser(getUid()) && !isFakeRoot(); /** * User's home directory path. * @type {any} */ let userHomeDir; if (isWindows()) { userHomeDir = path.resolve(home, './AppData/Local'); } else { userHomeDir = path.resolve(home, './.local/share'); } export { userHomeDir, home, isFakeRoot, isRootUser, ROOT_USER }; |