diff --git a/src/command-executor.ts b/src/command-executor.ts index dc6a3f70..4aaa7b12 100644 --- a/src/command-executor.ts +++ b/src/command-executor.ts @@ -1248,18 +1248,16 @@ export var releaseReact = (command: cli.IReleaseReactCommand): Promise => ) ) .then(() => { - if (platform === "android") { - return getHermesEnabled(command.gradleFile).then((isHermesEnabled) => { - if (isHermesEnabled) { - return runHermesEmitBinaryCommand( - bundleName, - outputFolder, - command.sourcemapOutput, - [] // TODO: extra flags - ); - } - }); - } + return getHermesEnabled(command.platform, command.gradleFile, command.podFile).then((isHermesEnabled) => { + if (isHermesEnabled) { + return runHermesEmitBinaryCommand( + bundleName, + outputFolder, + command.sourcemapOutput, + [] // TODO: extra flags + ); + } + }); }) .then(() => { out.text(chalk.cyan("\nReleasing update contents to CodePush:\n")); diff --git a/src/command-parser.ts b/src/command-parser.ts index e2f97554..6a4ec0b2 100644 --- a/src/command-parser.ts +++ b/src/command-parser.ts @@ -828,6 +828,12 @@ var argv = yargs demand: false, description: "Path to the gradle file which specifies the binary version you want to target this release at (android only).", }) + .option("podFile", { + alias: "pf", + default: null, + demand: false, + description: "Path to the cocopods config file (iOS only).", + }) .option("mandatory", { alias: "m", default: false, @@ -1316,6 +1322,7 @@ function createCommand(): cli.ICommand { releaseReactCommand.development = argv["development"]; releaseReactCommand.entryFile = argv["entryFile"]; releaseReactCommand.gradleFile = argv["gradleFile"]; + releaseReactCommand.podFile = argv["podFile"]; releaseReactCommand.mandatory = argv["mandatory"]; releaseReactCommand.noDuplicateReleaseError = argv["noDuplicateReleaseError"]; releaseReactCommand.plistFile = argv["plistFile"]; diff --git a/src/definitions/cli.ts b/src/definitions/cli.ts index 1b867452..649829d3 100644 --- a/src/definitions/cli.ts +++ b/src/definitions/cli.ts @@ -198,6 +198,7 @@ export interface IReleaseReactCommand extends IReleaseBaseCommand { development?: boolean; entryFile?: string; gradleFile?: string; + podFile?: string; platform: string; plistFile?: string; plistFilePrefix?: string; diff --git a/src/lib/react-native-utils.ts b/src/lib/react-native-utils.ts index ee9376a6..f9a41d46 100644 --- a/src/lib/react-native-utils.ts +++ b/src/lib/react-native-utils.ts @@ -398,7 +398,27 @@ export function runHermesEmitBinaryCommand( }); } -export function getHermesEnabled(gradleFile: string): Promise { +export function getHermesEnabled(platform: string, gradleFile?: string, podFile?: string): Promise { + if (platform === "ios") { + let podPath = path.join("ios", "Podfile"); + if (podFile) { + podPath = podFile; + } + if (fileDoesNotExistOrIsDirectory(podPath)) { + throw new Error(`Unable to find Podfile file "${podPath}".`); + } + + return new Promise((resolve, reject) => { + fs.readFile(podPath, { encoding: "utf8" }, (error, res) => { + if (error) { + reject(error); + return; + } + resolve(/:hermes_enabled(\s+|\n+)?=>(\s+|\n+)?true/.test(res)); + }); + }); + } + let buildGradlePath: string = path.join("android", "app"); if (gradleFile) { buildGradlePath = gradleFile;