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AAC,MAAM,eAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KACpC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAND,0CAMC;AAED,SAAgB,UAAU,CAAC,IAAY;IACrC,IAAI;QACF,OAAO,mBAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;KAChC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAND,gCAMC;AAED,SAAgB,sBAAsB,CACpC,WAAmB,EACnB,GAAwC;IAExC,MAAM,eAAe,GACnB,iBAAiB,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,eAAe,KAAK,QAAQ;QACjE,CAAC,CAAC,WAAI,CAAC,cAAO,CAAC,WAAW,EAAE,GAAG,CAAC,eAAe,CAAC,EAAE,cAAc,CAAC;QACjE,CAAC,CAAC,WAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IACxC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;QAChC,MAAM,IAAI,oBAAW,CACnB,mCAAmC,eAAe,iBAAiB,EACnE,kBAAkB,CACnB,CAAC;KACH;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAfD,wDAeC","sourcesContent":["import resolveFrom from 'resolve-from';\nimport { stat, statSync } from 'fs-extra';\nimport { join, resolve } from 'path';\nimport { ExpoConfig } from './Config.types';\nimport { ConfigError } from './Errors';\n\nexport function resolveModule(\n request: string,\n projectRoot: string,\n exp: Pick<ExpoConfig, 'nodeModulesPath'>\n): string {\n const fromDir = exp.nodeModulesPath ? exp.nodeModulesPath : projectRoot;\n return resolveFrom(fromDir, request);\n}\n\nexport function projectHasModule(\n modulePath: string,\n projectRoot: string,\n exp: Pick<ExpoConfig, 'nodeModulesPath'>\n): string | undefined {\n const fromDir = exp.nodeModulesPath ? exp.nodeModulesPath : projectRoot;\n return resolveFrom.silent(fromDir, modulePath);\n}\n\nexport function moduleNameFromPath(modulePath: string): string {\n if (modulePath.startsWith('@')) {\n const [org, packageName] = modulePath.split('/');\n if (org && packageName) {\n return [org, packageName].join('/');\n }\n return modulePath;\n }\n const [packageName] = modulePath.split('/');\n return packageName ? packageName : modulePath;\n}\n\nexport async function fileExistsAsync(file: string): Promise<boolean> {\n try {\n return (await stat(file)).isFile();\n } catch (e) {\n return false;\n }\n}\n\nexport function fileExists(file: string): boolean {\n try {\n return statSync(file).isFile();\n } catch (e) {\n return false;\n }\n}\n\nexport function getRootPackageJsonPath(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'nodeModulesPath'>\n): string {\n const packageJsonPath =\n 'nodeModulesPath' in exp && typeof exp.nodeModulesPath === 'string'\n ? join(resolve(projectRoot, exp.nodeModulesPath), 'package.json')\n : join(projectRoot, 'package.json');\n if (!fileExists(packageJsonPath)) {\n throw new ConfigError(\n `The expected package.json path: ${packageJsonPath} does not exist`,\n 'MODULE_NOT_FOUND'\n );\n }\n return packageJsonPath;\n}\n"]}
\No newline at end of file