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AC7B,MAAM,IAAI,oBAAW,CAAC,eAAe,UAAU,2BAA2B,EAAE,gBAAgB,CAAC,CAAC;KAC/F;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,gCAAoB,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC;IAC1F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACjB;AAAC,OAAO,KAAK,EAAE;IACd,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,oBAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;CAClB","sourcesContent":["#!/usr/bin/env node\nimport path from 'path';\n\nimport { ConfigError, errorToJSON } from '../Errors';\nimport { serializeAndEvaluate } from '../Serialize';\nimport { ConfigContext } from '../Config.types';\n\n'use strict';\n\n// Makes the script crash on unhandled rejections instead of silently\n// ignoring them. In the future, promise rejections that are not handled will\n// terminate the Node.js process with a non-zero exit code.\nprocess.on('unhandledRejection', err => {\n throw err;\n});\n\nconst { 3: configFileArg, 4: requestArg } = process.argv;\n\nlet request: ConfigContext | null = null;\n\nif (typeof requestArg === 'string') {\n try {\n request = JSON.parse(requestArg) as ConfigContext;\n } catch (_) {}\n}\n\ntry {\n const configFile = path.resolve(configFileArg);\n\n require('@babel/register')({\n only: [configFile],\n extensions: ['.ts', '.js'],\n presets: [require.resolve('@expo/babel-preset-cli')],\n });\n\n let result = require(configFile);\n if (result.default != null) {\n result = result.default;\n }\n const exportedObjectType = typeof result;\n if (typeof result === 'function') {\n result = result(request);\n }\n\n if (result instanceof Promise) {\n throw new ConfigError(`Config file ${configFile} cannot return a Promise.`, 'INVALID_CONFIG');\n }\n\n console.log(JSON.stringify({ config: serializeAndEvaluate(result), exportedObjectType }));\n process.exit(0);\n} catch (error) {\n console.error(JSON.stringify(errorToJSON(error)));\n process.exit(-1);\n}\n"]}
\No newline at end of file